diff --git a/CHANGELOG.md b/CHANGELOG.md index 94063fcc..efc73c28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ Notable FlexDoc product releases are recorded here. Detailed release notes remai ## Unreleased -- An implemented route that OpenAPI does not document fails `flexdoc validate` when runtime discovery is complete, and the failure names the method and path. Partial discovery keeps that finding a warning. `runtimeIntelligence.acknowledgedUndocumented` omits operations that are intentionally absent from the contract. Those routes stay in the runtime route list, and `summary.runtime` counts only `matched + runtimeOnly`. -- Opening that finding shows the registered route. It is not treated as an OpenAPI operation. +- An implemented route that OpenAPI does not document fails `flexdoc validate` when runtime discovery is complete, and the failure names the method and path. Partial discovery keeps that finding a warning. `runtimeIntelligence.acknowledgedUndocumented` records that route as acknowledged info. The route stays registered, `summary.runtime` still counts it, and the acknowledgement does not fail validation. +- Opening that finding shows the missing contract beside the registered method and path, and can send it from the API Client. The URL uses the snapshot `serverOrigin` when present, and is same-origin otherwise. The request asks to prefer the API host only when host execution is available and the server has not opted out. ## 3.4.0 — 3.3.x hardening package release diff --git a/adapters/elixir/assets/flexdoc.standalone.js b/adapters/elixir/assets/flexdoc.standalone.js index 3efc5433..bf78a4d9 100644 --- a/adapters/elixir/assets/flexdoc.standalone.js +++ b/adapters/elixir/assets/flexdoc.standalone.js @@ -1,86 +1,86 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(q,J){var oe=q.length;q.push(J);e:for(;0>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1>>1,we=q[he];if(0>>1;hes(me,ae))nes(Ce,me)?(q[he]=Ce,q[ne]=ae,he=ne):(q[he]=me,q[z]=ae,he=z);else if(nes(Ce,ae))q[he]=Ce,q[ne]=ae,he=ne;else break e}}return J}function s(q,J){var ae=q.sortIndex-J.sortIndex;return ae!==0?ae:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var we=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof we=="function"){b.callback=we,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=ae,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=ae,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,ae-he))):(q.sortIndex=we,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var ae=v;v=J;try{return q.apply(this,arguments)}finally{v=ae}}}})(vd)),vd}var Ng;function RA(){return Ng||(Ng=1,xd.exports=MA()),xd.exports}var wd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function($e){return $e})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ad.exports=_A(),Ad.exports}var Mg;function qA(){if(Mg)return oo;Mg=1;var t=RA(),e=Sd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1we||(i.current=he[we],he[we]=null,we--)}function me(i,l){we++,he[we]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function $e(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,a=Q2(l,i.type);l!==a&&(me(Ce,i),me(ne,a))}function ft(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oa._currentValue=ae)}var At,bt;function Ge(i){if(At===void 0)try{throw Error()}catch(a){var l=a.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",bt=-1)":-1m||$[d]!==te[m]){var fe=` -`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ge(a):""}function Se(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",a=null;do l+=Se(i,a),a=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var $e=Object.prototype.hasOwnProperty,We=t.unstable_scheduleCallback,vt=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ft=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,kt=t.unstable_NormalPriority,x=t.unstable_LowPriority,U=t.unstable_IdlePriority,pe=t.log,ue=t.unstable_setDisableYieldValue,X=null,k=null;function V(i){if(typeof pe=="function"&&ue(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var W=Math.clz32?Math.clz32:de,we=Math.log,F=Math.LN2;function de(i){return i>>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(ve(i)/F|0)|0}var le=256,Ae=262144,Te=4194304;function je(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,a){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=je(d):(S&=N,S!==0?m=je(S):a||(a=N&~i,a!==0&&(m=je(a))))):(N=d&~y,N!==0?m=je(N):S!==0?m=je(S):a||(a=d&~i,a!==0&&(m=je(a)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,a=l&-l,y>=a||y===32&&(a&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Te;return Te<<=1,(Te&62914560)===0&&(Te=4194304),i}function Fn(i){for(var l=[],a=0;31>a;a++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Fo(i,l,a,d,m,y){var S=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(a=S&~a;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var oR=/[\n"\\]/g;function vi(i){return i.replace(oR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,a,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):a!=null?gp(i,S,On(a)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,a,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}a=a!=null?""+On(a):"",l=l!=null?""+On(l):a,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,a){l==="number"&&ou(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Tl(i,l,a,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Go={};Object.defineProperty(Go,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Go,Go),window.removeEventListener("test",Go,Go)}catch{wp=!1}var es=null,Sp=null,cu=null;function Q1(){if(cu)return cu;var i,l=Sp,a=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Qo),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return LR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function BR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function $R(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),cu=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:a,offset:l-i};i=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=pw(a)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=ou(i.document);l instanceof i.HTMLIFrameElement;){try{var a=typeof l.contentWindow.location.href=="string"}catch{a=!1}if(a)i=l.contentWindow;else break;l=ou(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var YR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,ta=null,Rp=!1;function bw(i,l,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Rp||Rl==null||Rl!==ou(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),ta&&ea(ta,d)||(ta=d,d=nd(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|a<it?(dt=Ie,Ie=null):dt=Ie.sibling;var vt=ie(P,Ie,Z[it],ye);if(vt===null){Ie===null&&(Ie=dt);break}i&&Ie&&vt.alternate===null&&l(P,Ie),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt,Ie=dt}if(it===Z.length)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;itit?(dt=Ie,Ie=null):dt=Ie.sibling;var Ss=ie(P,Ie,vt.value,ye);if(Ss===null){Ie===null&&(Ie=dt);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),xt===null?Fe=Ss:xt.sibling=Ss,xt=Ss,Ie=dt}if(vt.done)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;!vt.done;it++,vt=Z.next())vt=xe(P,vt.value,ye),vt!==null&&(H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return pt&&gr(P,it),Fe}for(Ie=d(Ie);!vt.done;it++,vt=Z.next())vt=oe(Ie,P,it,vt.value,ye),vt!==null&&(i&&vt.alternate!==null&&Ie.delete(vt.key===null?it:vt.key),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return i&&Ie.forEach(function(fD){return l(P,fD)}),pt&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){a(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){a(P,H.sibling),ye=m(H,Z.props),oa(ye,Z),ye.return=P,P=ye;break e}a(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=xu(Z.type,Z.key,Z.props,null,P.mode,ye),oa(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){a(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{a(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,Nu(Z),ye);if(Z.$$typeof===j)return Et(P,H,Su(P,Z),ye);Tu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(a(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(a(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):a(P,H)}return function(P,H,Z,ye){try{la=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===ku)throw Ie;var xt=li(29,Ie,null,P.mode);return xt.lanes=ye,xt.return=P,xt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function os(i,l,a){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=bu(i),Cw(i,null,a),l}return yu(i,d,l,a),bu(i)}function aa(i,l,a){if(l=l.updateQueue,l!==null&&(l=l.shared,(a&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}function Zp(i,l){var a=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var m=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var S={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,a=a.next}while(a!==null);y===null?m=y=l:y=y.next=l}else m=y=l;a={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=l:i.next=l,a.lastBaseUpdate=l}var em=!1;function ca(){if(em){var i=zl;if(i!==null)throw i}}function ua(i,l,a,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,oe=ie!==N.lane;if(oe?(ut&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=a;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=m.callbacks,oe===null?m.callbacks=[ie]:oe.push(ie))}else oe={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=oe,$=xe):fe=fe.next=oe,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;oe=N,N=oe.next,oe.next=null,m.lastBaseUpdate=oe,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,a);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=t4($,d);ha(i,l,fe,di(i))}else ha(i,l,d,di(i))}catch(xe){ha(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function o4(){}function ym(i,l,a,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,ae,a===null?o4:function(){return AS(i),a(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ae},next:null};var a={};return l.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ha(i,l.next.queue,{},di())}function bm(){return yn(Oa)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function a4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var a=di();i=ls(a);var d=os(l,i,a);d!==null&&(Qn(d,l,a),aa(d,l,a)),l={cache:Kp()},i.payload=l;return}l=l.return}}function c4(i,l,a){var d=di();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bu(i)?TS(l,a):(a=qp(i,l,a,d),a!==null&&(Qn(a,i,d),jS(a,l,d)))}function NS(i,l,a){var d=di();ha(i,l,a,d)}function ha(i,l,a,d){var m={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,a);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return yu(i,l,m,0),Mt===null&&gu(),!1}catch{}if(a=qp(i,l,m,d),a!==null)return Qn(a,i,d),jS(a,l,d),!0}return!1}function xm(i,l,a,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Bu(i)){if(l)throw Error(r(479))}else l=qp(i,a,d,2),l!==null&&Qn(l,i,2)}function Bu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=Ou=!0;var a=i.pending;a===null?l.next=l:(l.next=a.next,a.next=l),i.pending=l}function jS(i,l,a){if((a&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}var pa={readContext:yn,use:Du,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};pa.useEffectEvent=zt;var ES={readContext:yn,use:Du,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,a){a=a!=null?a.concat([i]):null,Lu(4194308,4,gS.bind(null,l,i),a)},useLayoutEffect:function(i,l){return Lu(4194308,4,i,l)},useInsertionEffect:function(i,l){Lu(4,2,i,l)},useMemo:function(i,l){var a=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return a.memoizedState=[d,l],d},useReducer:function(i,l,a){var d=$n();if(a!==void 0){var m=a(l);if(Js){V(!0);try{a(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=c4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,a=NS.bind(null,nt,l);return l.dispatch=a,[i.memoizedState,a]},useDebugValue:mm,useDeferredValue:function(i,l){var a=$n();return gm(a,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,a){var d=nt,m=$n();if(pt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=l(),Mt===null)throw Error(r(349));(ut&127)!==0||Jw(d,l,a)}m.memoizedState=a;var y={value:a,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,a,l),null),a},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(pt){var a=Zi,d=Wi;a=(d&~(1<<32-W(d)-1)).toString(32)+a,l="_"+l+"R_"+a,a=Mu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,a),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,a=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,a)),i||is(l,!0)}else i=id(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(a=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),a!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else a=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return l.flags&256?(ai(l),l):(ai(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(ai(l),l):(ai(l),null)}return ai(l),(l.flags&128)!==0?(l.lanes=a,l):(a=d!==null,i=i!==null&&i.memoizedState!==null,a&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),a!==i&&a&&(l.child.flags|=8192),Uu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)ga(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Eu(i),y!==null){for(l.flags|=128,ga(d,!1),i=y.updateQueue,l.updateQueue=i,Uu(l,i),l.subtreeFlags=0,i=a,a=l.child;a!==null;)Nw(a,i),a=a.sibling;return me(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Ku&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304)}else{if(!m)if(i=Eu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Uu(l,i),ga(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Ku&&a!==536870912&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,a=Kt.current,me(Kt,m?a&1|2:a&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return ai(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(a&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),a=l.updateQueue,a!==null&&Uu(l,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==a&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),l.memoizedState.cache!==a&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function p4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ft(l),null;case 31:if(l.memoizedState!==null){if(ai(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(ai(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return ai(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:ft(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&ai(l);break;case 13:ai(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:ai(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function ya(i,l){try{var a=l.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var m=d.next;a=m;do{if((a.tag&i)===i){d=void 0;var y=a.create,S=a.inst;d=y(),S.destroy=d}a=a.next}while(a!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,a){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=a,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var a=i.stateNode;try{Fw(l,a)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,a){a.props=Qs(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(d){Nt(i,l,d)}}function ba(i,l){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof a=="function"?i.refCleanup=a(d):a.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var a=i.ref,d=i.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(m){Nt(i,l,m)}else a.current=null}function n2(i){var l=i.type,a=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,a){try{var d=i.stateNode;q4(d,i.type,a,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,l):(l=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,l.appendChild(i),a=a._reactRootContainer,a!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,a),i=i.sibling;i!==null;)qm(i,l,a),i=i.sibling}function Vu(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?a.insertBefore(i,l):a.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vu(i,l,a),i=i.sibling;i!==null;)Vu(i,l,a),i=i.sibling}function r2(i){var l=i.stateNode,a=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,a),l[_t]=i,l[Yt]=a}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,an=null;function m4(i,l){if(i=i.containerInfo,rg=ud,i=yw(i),Op(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var oe;xe!==a||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(oe=xe.firstChild)!==null;)ie=xe,xe=oe;for(;;){if(xe===i)break t;if(ie===a&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(oe=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=oe}a=N===-1||$===-1?null:{start:N,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(sg={focusedElem:i,selectionRange:a},ud=!1,an=l;an!==null;)if(l=an,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,an=i;else for(;an!==null;){switch(l=an,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a title"))),xn(y,d,a),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(a.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(oe.rangeCount!==1||oe.anchorNode!==P.node||oe.anchorOffset!==P.offset||oe.focusNode!==H.node||oe.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),oe.removeAllRanges(),Ye>Et?(oe.addRange(Z),oe.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),oe.addRange(Z))}}}}for(xe=[],oe=N;oe=oe.parentNode;)oe.nodeType===1&&xe.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Na?32:a,q.T=null,a=Fm,Fm=null;var y=ps,S=jr;if(ln=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,a),wt=N,ka(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,a){l=Si(a,l),l=Am(i.stateNode,l,2),i=os(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,a){if(i.tag===3)q2(i,i,a);else for(;l!==null;){if(l.tag===3){q2(l,i,a);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(a,i),a=BS(2),d=os(l,a,2),d!==null&&($S(a,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,a){var d=i.pingCache;if(d===null){d=i.pingCache=new b4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(a)||(Hm=!0,m.add(a),i=A4.bind(null,i,l,a),l.then(i,i))}function A4(i,l,a){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ut&a)===a&&(Ut===4||Ut===3&&(ut&62914560)===ut&&300>ht()-Yu?(wt&2)===0&&Zl(i,0):zm|=a,Ql===ut&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function k4(i){var l=i.memoizedState,a=0;l!==null&&(a=l.retryLane),B2(i,a)}function C4(i,l){var a=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(a=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,a)}function N4(i,l){return We(i,l)}var Zu=null,to=null,Xm=!1,ed=!1,Jm=!1,gs=0;function tr(i){i!==to&&i.next===null&&(to===null?Zu=to=i:to=to.next=i),ed=!0,Xm||(Xm=!0,j4())}function ka(i,l){if(!Jm&&ed){Jm=!0;do for(var a=!1,d=Zu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,z2(d,y))}else y=ut,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(a=!0,z2(d,y));d=d.next}while(a);Jm=!1}}function T4(){$2()}function $2(){ed=Xm=!1;var i=0;gs!==0&&$4()&&(i=gs);for(var l=ht(),a=null,d=Zu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,a===null?Zu=m:a.next=m,m===null&&(to=a)):(a=d,(i!==0||(y&3)!==0)&&(ed=!0)),d=m}ln!==0&&ln!==5||ka(i),gs!==0&&(gs=0)}function I2(i,l){for(var a=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function oA(i,l,a){var d=no;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof a=="string"&&(m+='[crossorigin="'+a+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:a,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function K4(i){Er.D(i),oA("dns-prefetch",i,null)}function G4(i,l){Er.C(i,l),oA("preconnect",i,l)}function X4(i,l,a){Er.L(i,l,a);var d=no;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&a&&a.imageSrcSet?(m+='[imagesrcset="'+vi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(m+='[imagesizes="'+vi(a.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=io(i);break;case"script":y=ro(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&a&&a.imageSrcSet?void 0:i,as:l},a),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(ja(y))||l==="script"&&d.querySelector(Ea(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function J4(i,l){Er.m(i,l);var a=no;if(a&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ro(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),a.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ea(y)))return}d=a.createElement("link"),xn(d,"link",i),Xt(d),a.head.appendChild(d)}}}function Q4(i,l,a){Er.S(i,l,a);var d=no;if(d&&i){var m=fr(d).hoistableStyles,y=io(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(ja(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},a),(a=ji.get(y))&&fg(i,a);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,sd(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function W4(i,l){Er.X(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Z4(i,l){Er.M(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function aA(i,l,a,d){var m=(m=Re.current)?rd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(l=io(a.href),a=fr(m).hoistableStyles,d=a.get(l),d||(d={type:"style",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=io(a.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(ja(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ji.set(i,a),y||eD(m,i,a,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=a.async,a=a.src,typeof a=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ro(a),a=fr(m).hoistableScripts,d=a.get(l),d||(d={type:"script",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function io(i){return'href="'+vi(i)+'"'}function ja(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function eD(i,l,a,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",a),Xt(l),i.head.appendChild(l))}function ro(i){return'[src="'+vi(i)+'"]'}function Ea(i){return"script[async]"+i}function uA(i,l,a){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(a.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),sd(d,a.precedence,i),l.instance=d;case"stylesheet":m=io(a.href);var y=i.querySelector(ja(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(a),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,sd(y,a.precedence,i),l.instance=y;case"script":return y=ro(a.src),(m=i.querySelector(Ea(y)))?(l.instance=m,Xt(m),m):(d=a,(m=ji.get(y))&&(d=b({},a),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,sd(d,a.precedence,i));return l.instance}function sd(i,l,a){for(var d=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function tD(i,l,a){if(a===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function nD(i,l,a,d){if(a.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var m=io(d.href),y=l.querySelector(ja(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=od.bind(i),l.then(i,i)),a.state.loading|=4,a.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),a.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,l),(l=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=od.bind(i),l.addEventListener("load",a),l.addEventListener("error",a))}}var pg=0;function iD(i,l){return i.stylesheets&&i.count===0&&cd(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function od(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ad=null;function cd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ad=new Map,l.forEach(rD,i),ad=null,od.call(i))}function rD(i,l){if(!(l.state.loading&4)){var a=ad.get(i);if(a)var d=a.get(null);else{a=new Map,ad.set(i,a);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),bd.exports=qA(),bd.exports}var $A=BA(),I=Sd();const kd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!o&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(o)?o:[o]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},o)=>I.createElement(VA,{ref:o,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _a=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Cd=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const ao=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Nd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Td=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const La=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const jd=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const Ed=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const co=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Od=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Md=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},qa={},Or={},Pg;function uo(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` -`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` -`,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` -`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentb&&(h=" ... ",o=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(o,c).replace(/\t/g,"→")+g,pos:u-o+h.length}}function n(s,o){return t.repeat(" ",o-s.length)+s}function r(s,o){if(o=Object.create(o||null),!s.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+o.linesAfter,f.length).toString().length,w=o.maxLength-(o.indent+v+3);for(let C=1;C<=o.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",o.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` +`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",o.indent)+n((s.line+1).toString(),v)+" | "+A.str+` +`,b+=t.repeat("-",o.indent+v+3+A.pos)+`^ +`;for(let C=1;C<=o.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",o.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Dd=r,Dd}var _d,Gg;function Mn(){if(Gg)return _d;Gg=1;const t=fo(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(o){const c={};return o!==null&&Object.keys(o).forEach(function(u){o[u].forEach(function(f){c[String(f)]=u})}),c}function s(o,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+o+'" YAML type.')}),this.options=c,this.tag=o,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return _d=s,_d}var Ld,Xg;function Jg(){if(Xg)return Ld;Xg=1;const t=fo(),e=Mn();function n(o,c){const u=[];return o[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(o.multi[u.kind].push(u),o.multi.fallback.push(u)):o[u.kind][u.tag]=o.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function o(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ud}var Vd,d0;function f0(){if(d0)return Vd;d0=1;const t=uo(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function o(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Vd=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:o,predicate:f,represent:u,defaultStyle:"lowercase"}),Vd}var Fd,h0;function p0(){return h0||(h0=1,Fd=r0().extend({implicit:[l0(),a0(),u0(),f0()]})),Fd}var Pd,m0;function g0(){return m0||(m0=1,Pd=p0()),Pd}var Yd,y0;function b0(){if(y0)return Yd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function o(c){return c.toISOString()}return Yd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:o}),Yd}var Kd,x0;function v0(){if(x0)return Kd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Kd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Kd}var Gd,w0;function S0(){if(w0)return Gd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function o(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Gd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:s}),Gd}var Xd,A0;function k0(){if(A0)return Xd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(o){if(o===null)return!0;const c={},u=o;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function ae(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function we(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function bt(x,U,pe){let ue,X,k,V,W,ve;const F=x.kind,de=x.result;let le=x.input.charCodeAt(x.position);if(R(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;le!==0;){if(le===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(le===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&ft(x)||pe&&_(le))break;if(O(le))if(V=x.line,W=x.lineStart,ve=x.lineIndent,$e(x,!1,-1),x.lineIndent>=U){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=ve;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))$e(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const ve=x.anchor;let F,de,le,Ae;const Te=Object.create(null);let je,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&ae(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if($e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=ve,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=je=ze=null,de=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=le=!0,x.position++,$e(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ht(x,U,o,!1,!0),Le=x.tag,je=x.result,$e(x,!0,U),Ve=x.input.charCodeAt(x.position),(le||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),$e(x,!0,U),ht(x,U,o,!1,!0),ze=x.result),Ae?He(x,W,Te,Le,je,ze,ue,X,k):de?W.push(He(x,null,Te,Le,je,ze,ue,X,k)):W.push(je),$e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function Se(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,ve=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` -`,de=we&&(k[k.length-2]===` +`,X?1+W:W),X=!0,k=!0,W=0;const le=x.position;for(;!O(de)&&de!==0;)de=x.input.charCodeAt(++x.position);Ce(x,le,x.position,!1)}return!0}function Ne(x,U){const pe=x.tag,ue=x.anchor,X=[];let k=!1;if(x.firstTabInLine!==-1)return!1;x.anchor!==null&&ae(x,x.anchor,X);let V=x.input.charCodeAt(x.position);for(;V!==0&&(x.firstTabInLine!==-1&&(x.position=x.firstTabInLine,q(x,"tab characters must not be used in indentation")),V===45);){const W=x.input.charCodeAt(x.position+1);if(!R(W))break;if(k=!0,x.position++,$e(x,!0,-1)&&x.lineIndent<=U){X.push(null),V=x.input.charCodeAt(x.position);continue}const ve=x.line;if(ht(x,U,u,!1,!0),X.push(x.result),$e(x,!0,-1),V=x.input.charCodeAt(x.position),(x.line===ve||x.lineIndent>U)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(je&&(X=x.line,k=x.lineStart,V=x.position),ht(x,U,f,!0,ue)&&(je?Ae=x.result:Te=x.result),je||(He(x,F,de,le,Ae,Te,X,k,V),le=Ae=Te=null),$e(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const je=k=V=f===pe||u===pe;if(ue&&$e(x,!0,-1)&&(ve=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&le.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&ae(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&($e(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if($e(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,$e(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),$e(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ft(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,$e(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==o||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==o&&k!==f&&k!==u}function He(k,V,W){const ve=qe(k),F=ve&&!Ce(k);return(W?ve:ve&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==o&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function $e(k){return!Ce(k)&&k!==j}function ft(k,V){const W=k.charCodeAt(V);let ve;return W>=55296&&W<=56319&&V+1=56320&&ve<=57343)?(W-55296)*1024+ve-56320+65536:W}function At(k){return/^\n* /.test(k)}const bt=1,Ge=2,Q=3,re=4,Se=5;function Ne(k,V,W,ve,F,de,le,Ae){let Te,je=0,Le=null,ze=!1,Ve=!1;const Dt=ve!==-1;let Fn=-1,jn=Je(ft(k,0))&&$e(ft(k,k.length-1));if(V||le)for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}else{for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),je===u)ze=!0,Dt&&(Ve=Ve||Te-Fn-1>ve&&k[Fn+1]!==" ",Fn=Te);else if(!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}Ve=Ve||Dt&&Te-Fn-1>ve&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!F(k)?bt:de===we?Se:Ge:W>9&&At(k)?Se:le?de===we?Se:Ge:Ve?re:Q}function Be(k,V,W,ve,F){k.dump=(function(){if(V.length===0)return k.quotingType===we?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===we?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=ve||k.flowLevel>-1&&W>=k.flowLevel;function Te(je){return ne(k,je)}switch(Ne(V,Ae,k.indent,le,Te,k.quotingType,k.forceQuotes&&!ve,F)){case bt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+lt(z(V,de));case re:return">"+We(V,k.indent)+lt(z(ti(V,le),de));case Se:return'"'+ht(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",ve=k[k.length-1]===` +`,de=ve&&(k[k.length-2]===` `||k===` -`)?"+":we?"":"-";return W+de+` -`}function vt(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`)?"+":ve?"":"-";return W+de+` +`}function lt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let ve=(function(){let Ae=k.indexOf(` `);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` -`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` -`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` -`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` -`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` -`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ -`)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); -const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` -`)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` -`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`||k[0]===" ",de,le;for(;le=W.exec(k);){const Ae=le[1],Te=le[2];de=Te[0]===" ",ve+=Ae+(!F&&!de&&Te!==""?` +`:"")+Tn(Te,V),F=de}return ve}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let ve,F=0,de,le=0,Ae=0,Te="";for(;ve=W.exec(k);)Ae=ve.index,Ae-F>V&&(de=le>F?le:Ae,Te+=` +`+k.slice(F,de),F=de+1),le=Ae;return Te+=` +`,k.length-F>V&&le>F?Te+=k.slice(F,le)+` +`+k.slice(le+1):Te+=k.slice(F),Te.slice(1)}function ht(k){let V="",W=0;for(let ve=0;ve=65536?ve+=2:ve++){W=ft(k,ve);const F=ce[W];!F&&Re(W)?(V+=k[ve],W>=65536&&(V+=k[ve+1])):V+=F||ae(W)}return V}function ni(k,V,W){let ve="";const F=k.tag;for(let de=0,le=W.length;de"u"&&U(k,V,null,!1,!1))&&(ve!==""&&(ve+=","+(k.condenseFlow?"":" ")),ve+=k.dump)}k.tag=F,k.dump="["+ve+"]"}function Vn(k,V,W,ve){let F="";const de=k.tag;for(let le=0,Ae=W.length;le"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!ve||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let ve="";const F=k.tag,de=Object.keys(W);for(let le=0,Ae=de.length;le1024&&(Te+="? "),Te+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Te+=k.dump,ve+=Te))}k.tag=F,k.dump="{"+ve+"}"}function kt(k,V,W,ve){let F="";const de=k.tag,le=Object.keys(W);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Te=le.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?je+="?":je+="? "),je+=k.dump,Ve&&(je+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?je+=":":je+=": ",je+=k.dump,F+=je)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const ve=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=ve.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Te}return!0}}return!1}function U(k,V,W,ve,F,de,le){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Te=ve;ve&&(ve=k.flowLevel<0||k.flowLevel>V);const je=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(je&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(je&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")ve&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")ve&&k.dump.length!==0?(k.noArrayIndent&&!le&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&Be(k,k.dump,V,de,Te);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],ve=[];ue(k,W,ve);const F=ve.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const o of r){if(s===null||typeof s!="object"||!(o in s))throw new Error(`Reference not found: ${n}`);s=s[o]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const o=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return o[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:o,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),o?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],tf={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(tf),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function nf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...tf[t]]:Cs.filter(n=>t.some(r=>r===n||tf[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function ho(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(o=>typeof o=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function Ba(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const o={...ho(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete o[e]:o[e]=c,o.expand===void 0&&o.sidebarCollapsed===void 0&&o.theme===void 0&&o.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(o))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],o=e[r]??s?.default;if(o===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(o))throw new Error(`Invalid value for server variable ${r}: ${o}`);return o})}function rf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const o=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of o)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return rf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=rf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const o=r.requestBody,c=o?Object.keys(o.content||{})[0]:void 0;if(c){s.contentType=c;const u=o.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function sf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=sf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,o])=>`${s}=${cn(o)}`).join(","):r.flatMap(([s,o])=>[s,cn(o)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=sf(e),o=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(o);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[o(f),o(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=o(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=sf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([o,c])=>[`${t.name}[${o}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(o=>[t.name,cn(o)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const o=Object.entries(s);return r?o.map(([c,u])=>[c,cn(u)]):[[t.name,o.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,o){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,o))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=o[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=rf(t,e,n),o=s.servers[0],c=r.serverUrl||(o?wk(o,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const o=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)o.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&o.push(` --data-raw ${un(t.body)}`),o.join(` \\ +`)}if(e==="javascript"){const o={method:t.method};return n.length&&(o.headers=t.headers),t.body&&(o.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(o,null,2)}); +const data = await response.json();`}if(e==="python"){const o=["import requests","",`url = ${un(t.url)}`];return n.length&&o.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&o.push(`body = ${un(t.body)}`),o.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),o.join(` +`)}if(e==="go"){const o=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${o})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` +`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[o,c]of n)r.push(` .header(${un(o)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var lf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,o=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=ae.value.length,ae=ae.next){var we=ae.value;if(j.length>O.length)return;if(!(we instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=ae.value.length;Re>=ne;)ae=ae.next,ne+=ae.value.length;if(ne-=ae.value.length,he=ne,ae.value instanceof f)continue;for(var Ce=ae;Ce!==j.tail&&(neM.reach&&(M.reach=$e);var ft=ae.prev;He&&(ft=v(j,ft,He),he+=He.length),w(j,ft,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(ae=v(j,ft,At),Je&&v(j,ae,Je),T>1){var bt={cause:G+","+B,reach:$e};g(O,j,R,ae.prev,he,bt),M&&bt.reach>M.reach&&(M.reach=bt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+o+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(o),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:o=!1})=>{const[c,u]=kd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${o?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:o=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(o.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(o);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:o})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:o},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:o})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:o})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function $a(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),o=Object.keys(r);return s.length===o.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function of(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const o=e(),c=of(o,r),u={key:r,value:String(s),enabled:!0};c>=0?o[c]=u:o.push(u)};return{get(r){const s=of(e(),r);return s>=0?e()[s].value:void 0},has(r){return of(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=$a(t.variables||{}),r=$a(t.collectionVariables||{}),s=$a(t.externalVariables||{}),o=$a(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(o,R)?n[R]=o[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return o[R]},has(R){return Object.prototype.hasOwnProperty.call(o,R)},set(R,_){const L=String(_);o[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete o[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(o,M)?o[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` -`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!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:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,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}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{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 n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.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 fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(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(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(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}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(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,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}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 n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` -`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;se.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",o=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${o}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const o=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>o.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:o}}function cf(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function Ia(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&Ia(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&Ia(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&Ia(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&Ia(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const o=Y0(n);if(o.length>0)throw new Error(`This request requires API host execution (${o.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=cf(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,o])=>({key:s,value:o})),body:t.body,contentType:cf(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:cf(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,o])=>({key:s,value:o,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function po(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const o=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return o&&!("$ref"in o)?o:void 0}function lC(t,e,n,r){const o=rC(t,e,n)?.security??t.security??[];if(!o.length)return;const c=o.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=o.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(o.find(f=>Object.keys(f).length===0)??o[0])}function oC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,o=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:o?.authorizationUrl,tokenUrl:o?.tokenUrl,scopes:n.length?n:Object.keys(o?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function aC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let o=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return o;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return o;if(!h)return{...o,auth:{type:"inherit"}};const g=oC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?o=X0(o,"Authorization"):g.type==="apiKey"&&g.in==="header"?o=X0(o,g.key):g.type==="apiKey"&&g.in==="query"&&(o=aC(o,g.key)),{...o,auth:g}):o}function uC(t,e,n,r,s){const o=B0(t,e,n,r);return{request:cC(t,e,n,r,o),serverUrl:r.serverUrl||s}}function Ha(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const uf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function df(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>df(e.key)?{...e,value:uf}:e)}function fC(t){return t?.map(e=>df(e[0])?[e[0],uf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const o=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return df(g)?`${h}=${encodeURIComponent(uf)}`:u}).join("&");return`${o}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Ha(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",o={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete o.responseBody,delete o.responseBodyTruncated,delete o.requestBodyTruncated),o});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Ha(n.auth)})),folders:t.folders.map(n=>({...n,auth:Ha(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Ha(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function mo(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function za(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function Ua(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!Ua(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Va(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function ff(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(ff(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Va(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(ff(t),JSON.stringify(wC(e))):sessionStorage.removeItem(ff(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(Ua))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(Ua))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(Ua))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Va(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Va(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Va(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const o=r.get(s.parentFolderId);(!o||o.collectionId!==s.collectionId||o.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const o=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(o.has(c)){s.parentFolderId=void 0;break}o.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!za(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!za(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!za(t,"runIndex")||!za(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,o])=>[s,o]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=mo();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function oy(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),o=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:o,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:o,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=o=>{if(o.length<=e)return e-=o.length,o;const c=o.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(o=>({...o,value:r(o.value)}))),s.formData&&(s.formData=s.formData.map(o=>({...o,value:r(o.value)}))),{request:s,truncated:n}}function ay(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),o={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:mo()};return{...t,history:[o,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),o=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!o.has(c.id);){if(o.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function hf(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function pf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),o=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,o=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});o=!0}if(!o)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:mo()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let o=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=o.filter(w=>w.key.trim()!==h);v.length!==o.length&&(o=v,c=!0);continue}const g=o.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];o[v]={...o[v],key:h,value:b,enabled:!0},g.length>1&&(o=o.filter((w,A)=>A===v||w.key.trim()!==h))}else o.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:o,updatedAt:mo()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=mo();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const o=e.transaction(tl,"readonly").objectStore(tl).get(t);o.onsuccess=()=>n(AC(t,oy(o.result))),o.onerror=()=>r(o.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const o=n.transaction(tl,"readwrite");o.objectStore(tl).put(Z0(e),t),o.oncomplete=()=>r(),o.onerror=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace")),o.onabort=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),o=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{o.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,o.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function mf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,o=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:mf(O,.5),p95Ms:mf(O,.95),p99Ms:mf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),o=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:o===null?null:new Date(o).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,o=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const gf=zC();function VC(t){gf.record(t)}function FC(){return gf.snapshot()}function PC(){gf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function yf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=yf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Fa(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,o]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${o}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Pa(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&po(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,o=t.hostExecution?.preferHostExecution,c=o===!1?!1:t.preferHostExecution??s??o??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Pa({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:o}of n){const c=s.file;r.append(`formData[${o}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=yf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let o=yf(t.request),c=Fa(t.variables),u=Fa(t.collectionVariables);const f=Fa(t.externalVariables);let h=Fa(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(o=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(o={...o,auth:t.resolveAuth(o.auth)}),o=nC(o,c),w=(o.method||"GET").toUpperCase(),A=o.url;const[j,,,R]=Pa({request:o,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(o);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(o);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function bf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:o="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":o,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Ya(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const o of e)n+=String.fromCharCode(o);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function oN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),o=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",o),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Ya(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function aN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||aN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const o=vy(48),c=await oN(o);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:o}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,o=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:o,scope:typeof n.scope=="string"?n.scope:void 0}}async function Ka(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},o=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&o?s.Authorization=`Basic ${lN(`${o}:${t.clientSecret||""}`)}`:(o&&e.set("client_id",o),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),o=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-osetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}const s=await cN(t,e.windowObject),o=await dN(s,e);if((o.searchParams.get("state")||new URLSearchParams(o.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(o.hash.replace(/^#/,"")),f=o.searchParams.get("error")||u.get("error");if(f){const b=o.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=o.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Ka(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Ya(t);return s&&r.set("scope",s),Ka(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,o]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{o(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{o(!1)}},w=async()=>{o(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{o(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},xf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:o,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>o(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>o({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:o}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>o({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>o({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>o({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>o({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>o({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>o({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>o({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>o({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>o({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>o({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>o({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>o({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>o({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>o({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>o({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>o({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>o({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>o({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let vf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=wf(t,e);for(e+=jy(r);e=0&&Ay(wf(t,c));)o++,c-=2;if(o%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new go(this),o=new go(e);for(let c=n,u=n;;){if(s.next(c),o.next(c),c=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new go(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.text[o],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let o=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ga(o.text,c.text.slice(),0,o.length);if(u.length<=32)r.push(new Vt(u,c.length+o.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ga(this.text,Ga(r.text,Ey(this.text,0,e)),n),o=this.length+r.length-(n-e);return s.length<=32?new Vt(s,o):Hi.from(Vt.split(s,[]),o)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;o<=n&&ce&&c&&(s+=r),eo&&(s+=u.slice(Math.max(0,e-o),n-o)),o=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let o of e)r.push(o),s+=o.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.children[o],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let o=0,c=0;c<=n&&o=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=o&&n<=u){let f=c.replace(e-o,n-o,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;oe&&o&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,o,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,o+=n){if(s==c||o==u)return r;let f=this.children[s],h=e.children[o];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),o=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>o&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ga(t,e,n=0,r=1e9){for(let s=0,o=0,c=!0;o=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],o=this.offsets[r],c=o>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new go(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},go.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const Sf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return o+(e-s);o+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?o:o+f;o+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Af(this,(n,r,s,o,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return kf(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,o=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,o.text),o.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],o=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||Sf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(o,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,o,g,b),s=h,o=g}}}function kf(t,e,n,r=!1){let s=[],o=r?[]:null,c=new yo(t),u=new yo(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),o.forward2(f),c.forward(f)}}}}class yo{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-o.from),n=e.indexOf(r);for(let s=1;so.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Cf=0;class Ue{constructor(e,n,r,s,o){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=Cf++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Nf),!!e.static,e.enables)}of(e){return new Xa([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Nf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Xa{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=Cf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,o=this.id,c=e[o]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Tf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[o];if(A!=null){let C=Za(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),o=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Ja).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let o=r.values[n],c=this.updateF(o,s);return this.compareF(o,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let o=r.facet(Ja),c=s.facet(Ja),u;return(u=o.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Ja.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function bo(t){return e=>new Ly(e,t)}const Qa={highest:bo(Ns.highest),high:bo(Ns.high),default:bo(Ns.default),low:bo(Ns.low),lowest:bo(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new jf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Wa{constructor(e,n,r,s,o,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=o,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],o=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(o[v.facet.id]||(o[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in o){let w=o[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Nf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Wa(e,c,b,u,f,o)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function o(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof jf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)o(h,u);else if(c instanceof jf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),o(h,u)}else if(c instanceof Ly)o(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&o(c.provides,u);else if(c instanceof Xa)r[u].push(c),c.facet.extensions&&o(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(h,u)}}return o(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function xo(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Za(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),Ef=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let o=s.map(n);o&&r.push(o)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,o,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=o,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),o.some(u=>u.type==rn.time)||(this.annotations=o.concat(rn.time.of(Date.now())))}static create(e,n,r,s,o,c){return new rn(e,n,r,s,o,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let o,c;if(r=t[r]))o=t[r++],c=t[r++];else if(s=0;s--){let o=r[s](t);o instanceof rn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof rn?t=o[0]:t=Vy(e,sl(o),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let o=n[s](t);o&&Object.keys(o).length&&(r=Uy(r,Of(e,o,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Mf;try{Mf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Mf)return Mf.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,o,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let o;n?o=e.startState.values.slice():(n=Wa.resolve(r,s,this),o=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(Ef)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),o=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Wa.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||Sf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(Ef)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(o,c)=>c.create(o),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>n.length?r:n[o-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let o of this.facet(qy))for(let c of o(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(o(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Rf(t,e,n={}){let r={};for(let s of t)for(let o of Object.keys(s)){let c=s[o],u=r[o];if(u===void 0)r[o]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,o))r[o]=n[o](u,c);else throw new Error("Config merge conflict for field "+o)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return _f.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Df(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let _f=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function Lf(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class qf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let o=r?this.to:this.from;for(let c=s,u=o.length;;){if(c==u)return c;let f=c+u>>1,h=o[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let o=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,o);oE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}o(C,E,v)}}return{mapped:c.length?new qf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:o=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(Lf)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new vo;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new vo),o.addRange(f,h,g,!1)};for(let f=0;f=o&&e<=o+c.length&&c.between(o,e-o,n-o,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return wo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return wo.from(e).goto(n)}static compare(e,n,r,s,o=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),f=Fy(c,u,r),h=new So(c,f,o),g=new So(u,f,o);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let o=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(o.length!=c.length)return!1;if(!o.length)return!0;let u=Fy(o,c),f=new So(o,u,0).goto(r),h=new So(c,u,0).goto(r);for(;;){if(f.to!=h.to||!$f(f.active,h.active)||f.point&&(!h.point||!Df(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,o=-1){let c=new So(e,null,o).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new vo;for(let s of e instanceof _f?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(Lf);e=r}return t}mt.empty.nextLayer=mt.empty;class vo{finishChunk(e){this.chunks.push(new qf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new vo)).addRange(e,n,r,s)}addInner(e,n,r,s){let o=e-this.lastTo||r.startSide-this.last.endSide;if(s&&o<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let o of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,o));return s.length==1?s[0]:new wo(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),Bf(this.heap,0)}}}function Bf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class So{constructor(e,n,r){this.minPoint=r,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=wo.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){ec(this.active,e),ec(this.activeTo,e),ec(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:o}=this.cursor;for(;n0;)n++;tc(this.active,n,r),tc(this.activeTo,n,s),tc(this.activeRank,n,o),e&&tc(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&ec(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,o){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!o.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Df(t.point,n.point)&&$f(t.activeForPoint(t.to),n.activeForPoint(n.to))||o.comparePoint(u,A,t.point,n.point),g=!1):(g&&o.boundChange(u),A>u&&!$f(t.active,n.active)&&o.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function $f(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;o+=t.charCodeAt(s)==9?n-o%n:1,s=kn(t,s)}return t.length}const If="ͼ",Gy=typeof Symbol>"u"?"__"+If:Symbol.for(If),Hf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ol{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function o(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))o(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");o(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)o(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,If+e.toString(36)}static mount(e,n,r){let s=e[Hf],o=r&&r.nonce;s?o&&s.setNonce(o):s=new IN(e,o),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let o=Jy.get(r);if(o)return e[Hf]=o;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Hf]=this}mount(e,n){let r=this.sheet,s=0,o=0;for(let c=0;c-1&&(this.modules.splice(f,1),o--,f=-1),f==-1){if(this.modules.splice(o++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Ao[dn]=String.fromCharCode(dn);for(var zf in $r)Ao.hasOwnProperty(zf)||(Ao[zf]=$r[zf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ao:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Uf=typeof document<"u"?document:{documentElement:{style:{}}};const Vf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Ff=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),ic=!!(Qy||Ff||Vf),Wy=!ic&&/gecko\/(\d+)/i.test(Dn.userAgent),Pf=!ic&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in Uf.documentElement.style,Yf=!ic&&/Apple Computer/.test(Dn.vendor),eb=Yf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:ic,ie_version:Qy?Uf.documentMode||6:Ff?+Ff[1]:Vf?+Vf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Pf,chrome_version:Pf?+Pf[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Yf,safari_version:Yf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:Uf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Kf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const rc=Object.create(null);function Gf(t,e,n){if(t==e)return!0;t||(t=rc),e||(e=rc);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let o of r)if(o!=n&&(s.indexOf(o)==-1||t[o]!==e[o]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:o,end:c}=nb(e,n);r=(o?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new Co(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}on.none=mt.empty;class ko extends on{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Kf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||rc}eq(e){return this==e||e instanceof ko&&this.tagName==e.tagName&&Gf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}ko.prototype.point=!1;class Co extends on{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Co&&this.spec.class==e.spec.class&&Gf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Co.prototype.mapMode=Wn.TrackBefore,Co.prototype.point=!0;class js extends on{constructor(e,n,r,s,o,c){super(n,r,o,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function al(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class No extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof No&&this.tagName==e.tagName&&Gf(this.attributes,e.attributes)}static create(e){return new No(e.tagName,e.attributes||rc,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}No.prototype.startSide=No.prototype.endSide=-1;function To(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Xf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function jo(t,e){if(!e.anchorNode)return!1;try{return Xf(t,e.anchorNode)}catch{return!1}}function lc(t){return t.nodeType==3?Oo(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Eo(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function oc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,o,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+o)):e.right>v.right-o&&(E=e.right-v.right+o,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let o=t.parentNode;o&&!(o==n.body||(!e||r)&&s);)if(o.nodeType==1)!s&&o.scrollHeight>o.clientHeight&&(s=o),e&&!r&&o.scrollWidth>o.clientWidth&&(r=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:r,y:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ob(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ab(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ob(e))}let cb;function Oo(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),o.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!oc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(o<0||(s!=0?s<0?u.fromn:e[o].level>u.level))&&(o=c)}}if(o<0)throw new RangeError("Index out of range");return o}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?o:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,o=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else o=h,f++}}}function Wf(t,e,n,r,s,o,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Zf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Wf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>o[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==o[h-1].to){if(b)break e;let C=o[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&o[D-1].to==E)E=o[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Zf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var o;let c=r.head-t.from,u=Vi.find(e,c,(o=r.bidiLevel)!==null&&o!==void 0?o:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,o,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=o,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const cc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(uc.of(h=>{let g=h.plugin(u);return g?c(g):on.none})),o&&f.push(o(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class ih{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),rh=Ue.define(),uc=Ue.define(),Eb=Ue.define(),sh=Ue.define(),Mo=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(o=>o instanceof Function?o(t):o),s=[];return mt.spans(r,e.from,e.to,{point(){},span(o,c,u,f){let h=o-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let o of t.state.facet(Rb)){let c=o(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ro=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(o,c,u,f))),this.changedRanges=s}static create(e,n,r){return new dc(e,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}}const oT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return oT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 hc)return e;return null}static get(e){return e.cmTile}}class fc extends Ht{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 n=this.dom,r=null,s,o=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,o&&s!=u.dom&&(o.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,o&&s&&(o.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hc extends fc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,o=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&o++,s=n.pop()}else{let c=r.children[s++];if(c instanceof or)n.push(s),r=c,s=0;else{let u=o+c.length,f=e(c,o);if(f!==void 0)return f;o=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,o,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,c=e-f)}}),!r&&!o)throw new Error("No tile at position "+e);return r&&n<0||!o?{tile:r,offset:s}:{tile:o,offset:c}}}class or extends fc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new or(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends fc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,o=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,o=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?o:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):aT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:o}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,o)):s.domPosFor(o,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function aT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=lc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let o=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(o--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let o=this.dom.getClientRects(),c=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;c=o[f],!(e>0?f==0:f==o.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:o,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(o==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:o}=u.pop(),o++}else{let f=s.children[o],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(lh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(lh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let o=Ht.get(e.text);o&&this.cache.reused.set(o,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let o=this.ensureMarks(n,r);!s&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let o=e.length-1;o>=0;o--){let c=e[o],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(oh,0,32)||new Rs(oh.toDOM(),0,oh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(o),n=o}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(pc,void 0,1);return r&&(r.flags=n),r||new pc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:o,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return o?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const mc=[Rs,fl,Ms,Hn,pc,or,hc];for(let t=0;t[]),this.index=mc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,o=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,o=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,o+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=o=0):c instanceof Hn&&(s.shift(),o=Math.min(o,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,o=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>o),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let o=Ht.get(s);if(s==this.view.contentDOM)break;o instanceof Hn?n.push(o):o?.isLine()?r=o:o instanceof or||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new ko({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Kf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function lh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends sc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const oh=new class extends sc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=on.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 hc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let o=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Oe.ie||Oe.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),o&&!r.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(r=o.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 o=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||r.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&jo(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(o||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!Eo(h.node,h.offset,b.anchorNode,b.anchorOffset)||!Eo(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=To(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=To(e.root),{anchorNode:s,anchorOffset:o}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,o)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let o;if(e==r.dom)o=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?o=e:o=e.nextSibling}if(o==r.dom.firstChild)return s;for(;o&&!Ht.get(o);)o=o.nextSibling;if(!o)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,o=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(o=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,o=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(o&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:o}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof ch?null:s.coordsInWidget(o,n,!0):s.coordsIn(o,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(o,c){if(o.isComposite())for(let u of o.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(o.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof or)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?lc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=o,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=lc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,o;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=lc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,o=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:o}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let o=s==n.viewports.length?null:n.viewports[s],c=o?o.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(on.replace({widget:new ch(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!o)break;r=o.to+1}return on.set(e)}updateDeco(){let e=1,n=this.view.state.facet(uc).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),r=!1,s=this.view.state.facet(sh).map((o,c)=>{let u=typeof o=="function";return u&&(r=!0),u?o(this.view):o});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Db(this.view),c={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),o=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=r,!o)return null;let c=e-o.offset;return{from:c,to:c+o.node.nodeValue.length,node:o.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:o,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(o),f.mapPos(c),o,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class ch extends sc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(s.length==0)return ke.cursor(e);o==0?n=1:o==s.length&&(n=-1);let c=o,u=o;n<0?c=kn(s.text,o,!1):u=kn(s.text,o);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);o+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,o,t.state.tabSize)}function uh(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let o of r.type){if(o.from>e)break;if(!(o.toe)return o;(!s||o.type==fn.Text&&(s.type!=o.type||(n<0?o.frome)))&&(s=o)}}return s||r}return r}function OT(t,e,n,r){let s=uh(t,e.head,e.assoc||-1),o=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(o){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(o.top+o.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,o,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),o=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return o=>{let c=r(o);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,o=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=o<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(o<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*o,E=fh(t,{x:b,y:C},!1,o);if(n?C>f.bottom:Cu:O{if(e>o&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+o:v.bottom>=f+o))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=o&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let o=0;o{let c=r[o]-n,u=r[o+1]-n;return Oo(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Oo(f.dom,0,f.length)).getClientRects()}),o=e.children[s.i],c=r[s.i];return o.isText()?this.scanText(o,c):o.isComposite()?this.scanTile(o,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let o=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:oc(s))||oc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>o)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,c=1,u;if(this.lineSeparator?(o=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(o=u.index,c=u[0].length),this.append(n.slice(r,o<0?n.length:o)),o<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=o+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:o,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=o||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!Xf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Xf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,o=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,o=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:o,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,o=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=o.from,g=null;(c===8||Oe.android&&e.text.length=u&&o.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&b.slice(o.to-u)==e.text.slice(v=e.text.length-(b.length-(o.to-u)))?n={from:o.from,to:o.to,insert:gt.of(e.text.slice(o.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||gc(r,o))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(o.from).toDate.now()-50?n={from:o.from,to:o.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:o.from,to:o.to,insert:gt.of([" "])}),n)return hh(t,n,r,c);if(r&&!gc(r,o)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Mo).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function hh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,o,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,o=s.selection.main,c=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=o.frome.to?s.sliceDoc(e.to,o.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(o.head);let w=o.to-e.to;r=s.changeByRange(A=>{if(A.from==o.from&&A.to==o.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-o.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),o=0;for(;o0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,o-Math.min(c,u));n-=c+f-o}if(c=c?o-n:0;o-=f,u=o+(u-c),c=o}else if(u=u?o-n:0;o-=f,c=o+(c-u),u=o}return{from:o,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||o!=r)&&e.push(new zb(s,o))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function gc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let o in n)if(o!="scroll"){let c=!n[o].handlers.length,u=r[o];u&&c!=!u.handlers.length&&(s.removeEventListener(o,this.handleEvent),u=null),u||s.addEventListener(o,this.handleEvent,{passive:c})}for(let o in r)o!="scroll"&&!n[o]&&s.removeEventListener(o,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,o=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],yc=6;function bc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Mo).map(c=>c(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,o=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+yc?n=-bc(s-e.clientX):e.clientX+f.right>=c-yc&&(n=bc(e.clientX-c)),e.clientY-f.top<=o+yc?r=-bc(o-e.clientY):e.clientY+f.bottom>=u-yc&&(r=bc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=To(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function xc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=xc(t.state,th,e);let{state:n}=t,r,s=1,o=n.toText(e),c=o.lines==n.selection.ranges.length;if(ph!=null&&n.selection.ranges.every(f=>f.empty)&&ph==o.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?o.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=o.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(o);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ab(t.contentDOM);let o=t.root.activeElement;o&&!o.contains(t.contentDOM)&&o.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),o=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:o.from,u=s?s.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(o){o.docChanged&&(n.pos=o.changes.mapPos(n.pos),s=s.map(o.changes))},get(o,c,u){let f=t.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let o=s.posAtStart,c=o+s.length;(o>=n.to||c<=n.from)&&(n=ke.undirectionalRange(o,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",xc(t.state,nh,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=xc(t.state,th,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,c=r&&o&>(t,e)?{from:o.from,to:o.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,o=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),o()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let c=t.doc.lineAt(o);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:xc(t,nh,e.join(t.lineBreak)),ranges:n,linewise:r}}let ph=null;Mi.copy=Mi.cut=(t,e)=>{if(!jo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;ph=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=Gb?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let o=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(o&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return hh(t,{from:f,to:h,insert:t.state.toText(o)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(o=>o.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>o+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ox(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=o,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>vc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let o=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=o.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:o.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fo*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(o>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,o-=u.size}else break;else if(s=o&&c(this.lineAt(0,Rt.ByPos,r,s,o))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ax{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,o=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);c=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else c=this.height/o;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:o,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let o=r[r.length-1];o instanceof hn?r[r.length-1]=new hn(o.length+s):r.push(null,new hn(s-1))}if(e>0){let o=r[0];o instanceof hn?r[0]=new hn(e+o.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let o=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=o&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=vc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=o&&c.push(null,new hn(o-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=vc||Math.abs(f-this.heightMetrics(e,n).perLine)>=vc)&&(ml=!0),wc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class oj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let o=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,o).join(h)}forEachLine(e,n,r,s,o,c){let u=s+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,o);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let o=[];e>0&&this.decomposeLeft(e,o);let c=o.length;for(let u of r)o.push(u);if(e>0&&cx(o,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=wc(this.left,e),this.right=wc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:o,right:c}=this,u=n+o.length+this.break,f=null;return s&&s.from<=n+o.length&&s.more?f=o=o.updateHeight(e,n,r,s):o.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(o,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const aj=5;class mh{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=aj)&&this.addLineDeco(s,o,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();o=Math.max(o,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:o-n.left,right:Math.max(o,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class gh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=on.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:o,to:c})=>s>=o&&s<=c)){let{from:o,to:c}=this.lineBlockAt(s);e.push(new Sc(o,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new yh(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(_o(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,o=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ox(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,o=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(o,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ox();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,o=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new Sc(s.lineAt(c-r*1e3,Rt.ByHeight,o,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,o,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,o,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&o>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new gh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(o,c){r.push({from:o,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||_o(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||_o(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return _o(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}}class Sc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,o=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),o+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:o,to:c}=e[s],u=c-o;if(r<=u)return o+r;r-=u}}function kc(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(uc).filter(r=>typeof r!="function"),n=t.facet(sh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class yh{constructor(e,n,r){let s=0,o=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-o)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),o=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let o=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function _o(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>_o(s,e)):t._content)}const Cc=Ue.define({combine:t=>t.join(" ")}),bh=Ue.define({combine:t=>t.indexOf(!0)>-1}),xh=ol.newName(),hx=ol.newName(),px=ol.newName(),mx={"&light":"."+hx,"&dark":"."+px};function vh(t,e,n){return new ol(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=vh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),wh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!jo(this.dom,s))return;let o=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&Eo(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=To(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=jo(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&cl(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let o of e){let c=this.readMutation(o);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&jo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!gc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return Eo(c.node,c.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:o,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&othis.to&&(f=o);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));gc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);hh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],o=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let o of r.getTextFormats()){let c=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),h=this.toEditorPos(o.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=To(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((o,c,u,f,h)=>{if(r)return;let g=h.length-(c-o);if(s&&c>=s.to)if(s.from==o&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(o+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(othis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(o=>r(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(cc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new ih(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,o=this.state;for(let v of e){if(v.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=v.state}if(this.destroyed){this.viewState.state=o;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(o,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(g=null)):this.observer.clear(),o.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(o);s=dc.create(this,o,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(cc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Nc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Cc)!=s.state.facet(Cc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(eh))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new ih(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let o of r){let c=n.indexOf(o);if(c<0)s.push(new ih(o));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))o=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);o=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=dc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?o<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(eh))f(n)}get themeClasses(){return xh+" "+(this.state.facet(bh)?px:hx)+" "+this.state.facet(Cc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,rh,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),o=tb(this.dom,this.editorAttrs,e);return s||o});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let e=this.state.facet(Xe.cspNonce);ol.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return dh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return dh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),o=r[n?r.length-1:0];return ke.cursor(o.side(n,s)+e.from,o.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return dh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=fh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),fh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,o.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==n&&(o.fresh||mb(o.isolates,r=Mb(this,e))))return o.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Nc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(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,n={}){var r,s,o,c;return cc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(o=n.yMargin)!==null&&o!==void 0?o:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return cc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=ol.newName(),s=[Cc.of(r),Ro.of(vh(`.${r}`,e))];return n&&n.dark&&s.push(bh.of(!0)),s}static baseTheme(e){return Qa.lowest(Ro.of(vh("."+xh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ro,Xe.inputHandler=Sb,Xe.clipboardInputFilter=th,Xe.clipboardOutputFilter=nh,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=eh,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=uc,Xe.blockWrappers=Eb,Xe.outerDecorations=sh,Xe.atomicRanges=Mo,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=bh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=rh,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Nc{constructor(e,n,r,s,o,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=o,this.order=c}static update(e,n){if(n.empty&&!e.some(o=>o.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let o=Math.max(0,e.length-10);o=0;s--){let o=r[s],c=typeof o=="function"?o(t):o;c&&Kf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,o,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},o=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,Sh))}let f=c[e]||c.key;if(f)for(let h of u)o(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&o(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let Sh=null;function Ej(t,e,n,r){Sh=e;let s=UN(e),o=kN(s,0),c=CN(o)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Tc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Tc(A,e,!0)])||e.shiftKey&&(C=Ao[e.keyCode])!=s&&C!=A&&v(w[u+Tc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Tc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),Sh=null,f}class Ds{constructor(e,n,r,s,o){this.className=e,this.left=n,this.top=r,this.width=s,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let o=Sx(e);return[new Ds(n,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let o=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:o.left+1,y:c}),f=t.posAtCoords({x:o.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),o=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=uh(t,r,1),A=uh(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;we>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(we,q),L==null&&we>=be,ae.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(jc)!=e.state.facet(jc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(jc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const jc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),jc.of(t)]}const gl=Ue.define({combine(t){return Rf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(o&&Oe.ios&&n.iosSelectionHandles)){let c=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let o of Ds.forRange(t,"cm-selectionBackground",s))e.push(o);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Qa.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=on.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return on.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const Ec=Ue.define(),Hj=Ue.define(),Oc=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Oc).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Ec),this.view.viewport.from),r=[],s=this.gutters.map(o=>new Vj(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let c=!0;for(let u of o.type)if(u.type==fn.Text&&c){Ah(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(o.type==fn.Text){Ah(n,r,o.from);for(let c of s)c.line(this.view,o,r)}else if(o.widget)for(let c of s)c.widget(this.view,o);for(let o of s)o.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Oc),n=t.state.facet(Oc),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Ec),t.state.facet(Ec),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let o of n){let c=e.indexOf(o);c<0?s.push(new Ox(this.view,o)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let o of this.gutters)o.dom.remove(),s.indexOf(o)<0&&o.destroy();for(let o of s)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Ah(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,o=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,o,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,o,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Ah(this.cursor,s,n.from),r.length&&(s=s.concat(r));let o=this.gutter.config.lineMarker(e,n,s);o&&s.unshift(o);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let o of e.state.facet(Hj)){let c=o(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let o=s.target,c;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let o=0,c=0;;){let u=c,f=oo(u,f,h)||c(u,f,h):c}return r}})}});class kh extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ch(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Oc.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new kh(Ch(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let o=s(e,n,r);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new kh(Ch(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=Ch(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new kh(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Nh{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class Lo{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(s)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return s}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 n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),o=-1;o<(s?s.length:0);o++){let c=n[o<0?r.name:s[o]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Mc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,o){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,o&&o.length){this.props=Object.create(null);for(let[c,u]of o)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=Lo.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Eh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Mc.get(this)||this.topNode,o=new Eh(s);return o.moveTo(e,n),Mc.set(this,o._tree),o}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=qo(Mc.get(this)||this.topNode,e,n,!1);return Mc.set(this,r),r}resolveInner(e,n=0){let r=qo(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:o=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=o&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Mh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Th{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Th(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,o=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function qo(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(o&Pt.EnterBracketed&&g instanceof pn&&(v=Lo.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(o&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(o&Pt.IncludeAnonymous||!g.type.isAnonymous||Oh(g)){let w;if(!(o&Pt.IgnoreMounts)&&(w=Lo.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return o&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,o)}}}if(o&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=Lo.get(this._tree))&&s.overlay){let o=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=o:u=o:f>o))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return o}for(;;){if(r!=null&&s.type.is(r))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return r==null?o:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,o=r.buffer[this.index+3];if(o>s){let c=r.buffer[this.index+1];e.push(r.slice(s,o,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let o=1;on.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+o.from,-1,o);(s||(s=[r])).push(qo(u,e,n,!1))}}return s?Ix(s):r}class Eh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let o=n+e,c=e<0?-1:r._tree.children.length;o!=c;o+=e){let u=r._tree.children[o];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Oh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=o+1;break e}s=this.stack[--o]}for(let s=r;s=0;o--){if(o<0)return jh(this._tree,e,s);let c=r[n.buffer[this.stack[o]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Oh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Oh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:o=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Th(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=o[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],ae,he,we=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);ae=new Ur(T,be-he.start,r),we=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);ae=Mh(J,z,me,0,z.length,0,be-ee,qe,qe)}else ae=C(J,z,me,be-ee,ge-be,q)}M.push(ae),G.push(we)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(yt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[yt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[yt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Rc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Rc(t,r)}Hx.set(e,n)}return n}function Mh(t,e,n,r,s,o,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Mh(t,A,C,R,j,_,M,null,f))}v.push(_+O-o)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,o=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(o?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let o of n)o.to>e.length&&s.push(o);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],o=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=onew Nh(s.from,s.to)):[new Nh(0,0)]:[new Nh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let o=s.advance();if(o)return o}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let o of n.set)s.set.push(o);return s}static defineModifier(e){let n=new Dc(e);return r=>r.modified.indexOf(n)>-1?r:Dc.get(r.base||r,r.modified.concat(n).sort((s,o)=>s.id-o.id))}}let lE=0;class Dc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&oE(n,u.modified));if(r)return r;let s=[],o=new yi(e.name,s,e,n);for(let u of n)u.instances.push(o);let c=aE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Dc.get(u,f));return o}}function oE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function aE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let o=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(o.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=o.length-1,h=o[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new _c(r,c,f>0?o.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let o=new _c(s.tags,s.mode,s.context);n?n.next=o:r=o,n=o}return r}});class _c{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of o)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const Ee=yi.define,Lc=Ee(),Fr=Ee(),zx=Ee(Fr),Ux=Ee(Fr),Pr=Ee(),qc=Ee(Pr),Rh=Ee(Pr),Yi=Ee(),Ls=Ee(Yi),Ki=Ee(),Gi=Ee(),Dh=Ee(),Bo=Ee(Dh),Bc=Ee(),rt={comment:Lc,lineComment:Ee(Lc),blockComment:Ee(Lc),docComment:Ee(Lc),name:Fr,variableName:Ee(Fr),typeName:zx,tagName:Ee(zx),propertyName:Ux,attributeName:Ee(Ux),className:Ee(Fr),labelName:Ee(Fr),namespace:Ee(Fr),macroName:Ee(Fr),literal:Pr,string:qc,docString:Ee(qc),character:Ee(qc),attributeValue:Ee(qc),number:Rh,integer:Ee(Rh),float:Ee(Rh),bool:Ee(Pr),regexp:Ee(Pr),escape:Ee(Pr),color:Ee(Pr),url:Ee(Pr),keyword:Ki,self:Ee(Ki),null:Ee(Ki),atom:Ee(Ki),unit:Ee(Ki),modifier:Ee(Ki),operatorKeyword:Ee(Ki),controlKeyword:Ee(Ki),definitionKeyword:Ee(Ki),moduleKeyword:Ee(Ki),operator:Gi,derefOperator:Ee(Gi),arithmeticOperator:Ee(Gi),logicOperator:Ee(Gi),bitwiseOperator:Ee(Gi),compareOperator:Ee(Gi),updateOperator:Ee(Gi),definitionOperator:Ee(Gi),typeOperator:Ee(Gi),controlOperator:Ee(Gi),punctuation:Dh,separator:Ee(Dh),bracket:Bo,angleBracket:Ee(Bo),squareBracket:Ee(Bo),paren:Ee(Bo),brace:Ee(Bo),content:Yi,heading:Ls,heading1:Ee(Ls),heading2:Ee(Ls),heading3:Ee(Ls),heading4:Ee(Ls),heading5:Ee(Ls),heading6:Ee(Ls),contentSeparator:Ee(Yi),list:Ee(Yi),quote:Ee(Yi),emphasis:Ee(Yi),strong:Ee(Yi),link:Ee(Yi),monospace:Ee(Yi),strikethrough:Ee(Yi),inserted:Ee(),deleted:Ee(),changed:Ee(),invalid:Ee(),meta:Bc,documentMeta:Ee(Bc),annotation:Ee(Bc),processingInstruction:Ee(Bc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var _h;const $c=new yt,fE=new yt;class ar{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((o,c,u)=>{let f=Vx(o,c,u),h=f.type.prop($c);if(!h)return[];let g=o.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,o)){let A=o.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop($c)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(o,c)=>{if(o.prop($c)==this.data){r.push({from:c,to:c+o.length});return}let u=o.prop(yt.mounted);if(u){if(u.tree.prop($c)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+o.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let $o=null;class Ic{constructor(e,n,r=[],s,o,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=o,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Ic(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=$o;$o=this;try{return e()}finally{$o=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:o,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,o=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let o=s[0].from,c=s[s.length-1].to;return{parsedPos:o,advance(){let f=$o;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return $o}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Ic.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}ar.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(ar.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Lh=typeof navigator<"u"&&(!((_h=navigator.scheduling)===null||_h===void 0)&&_h.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=o.context.work(()=>Lh&&Lh()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ar.setState.of(new bl(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[ar.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),qh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Hc(t){let e=t.facet(qh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function zc(t,e){let n="",r=t.tabSize,s=t.facet(qh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let o=0;o=e?yE(t,n,e):null}class Uc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Hc(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:o}=this.options;return s!=null&&s>=r.from&&s<=r.to?o&&s==e?{text:"",from:e}:(n<0?s-1&&(o+=c-this.countColumn(r,r.search(/\S|$/))),o}countColumn(e,n=e.length){return nc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),o=this.options.overrideIndentation;if(o){let c=o(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let o=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)o.push(c);for(let c=o.length-1;c>=0;c--)r={node:o[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(Bh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,o=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,o&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class Bh extends Uc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Bh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(n.from),c=s==null||s<=o.from?o.to:Math.min(o.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let o=t.textAfter,c=o.match(/^\s*/)[0].length,u=r&&o.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function $h(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function Ih(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,o=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=$h(f.type,n,o);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,o)}}return jE(t,e,n,c,u.type,s,o)}function TE(t,e,n,r,s,o,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&o.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=o;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Hh(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Hh(h,`Modifier ${h} used at start of tag`):f.length?Hh(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Hh(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),o=Jx[s];if(o)return o.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Uh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function zh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=zh($E,0),_E=zh(Qx,0),LE=zh((t,e)=>Qx(t,e,BE(e)),0);function Uh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Io=50;function qE(t,{open:e,close:n},r,s){let o=t.sliceDoc(r-Io,r),c=t.sliceDoc(s,s+Io),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(c)[0].length,h=o.length-u;if(o.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*Io?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+Io),b=t.sliceDoc(s-Io,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(o=>Uh(e,o.from).block);if(!r.every(o=>o))return null;let s=n.map((o,c)=>qE(e,r[c],o.from,o.to));if(t!=2&&!s.every(o=>o))return{changes:e.changes(n.map((o,c)=>s[c]?[]:[{from:o.from,insert:r[c].open+" "},{from:o.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(o=>o)){let o=[];for(let c=0,u;cs&&(o==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;vo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&o.push({from:u.from+h,insert:f+" "});let c=e.changes(o);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,o.push({from:h,to:g})}return{changes:o}}return null}const Vh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Rf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Vh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Fc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return o?t=t.addChanges(o,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Fh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Vc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let o=s.pop(t,n,e);return o?(r(o),!0):!1}}const ev=Vc(0,!1),Fh=Vc(1,!1),UE=Vc(0,!0),VE=Vc(1,!0);class zn{constructor(e,n,r,s,o){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=o}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let o=s(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Fc(t,e,n,r){let s=e+1>n+20?e-n-1:0,o=t.slice(s,e);return o.push(r),o}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,o)=>n.push(s,o)),e.iterChangedRanges((s,o,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Fc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Ph(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let o=t.slice(0,n);return o[n-1]=s,o}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(o):o;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(o),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,o){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Pc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function ov(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Pc(n,e))}const JE=t=>ov(t,!Nn(t)),QE=t=>ov(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let o=r.type.prop(s),c,u;return o&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Yc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Yc(t.state,e,Nn(t)));function av(t,e){return _i(t,n=>{if(!n.empty)return Pc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>av(t,!1),uv=t=>av(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Pc(c,e));if(s.eq(r.selection))return!1;let o;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Yh=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(s=ke.cursor(r.from+o))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function oO(t,e,n){let r=!1,s=wl(t.selection,o=>{let c=vl(t,o.head,-1)||vl(t,o.head,1)||o.head>0&&vl(t,o.head-1,1)||o.headoO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let o=n(s);return ke.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Yc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Yc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Gc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),o=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let o of n.selection.ranges){let c=n.doc.lineAt(o.head);if(e?c.to0)for(let u=o;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ho(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(o=>{let{from:c,to:u}=o;if(c==u){let f=e(o);fc&&(n="delete.forward",f=Kc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Kc(t,c,!1),u=Kc(t,u,!0);return c==u?{range:o}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,o)=>{se&&(e=n?o:s)});return e}const Ev=(t,e,n)=>Ho(t,r=>{let s=r.from,{state:o}=t,c=o.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ho(t,n=>{let r=n.head,{state:s}=t,o=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?o.to:o.from)){r==n.head&&o.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(o.text,r-o.from,e)+o.from,h=o.text.slice(Math.min(r,f)-o.from,Math.max(r,f)-o.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ho(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headHo(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ho(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,o=t.doc.lineAt(s),c=s==o.from?s-1:kn(o.text,s-o.from,!1)+o.from,u=s==o.to?s+1:kn(o.text,s-o.from,!0)+o.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=o.to,c.ranges.push(r)}else e.push({from:s.from,to:o.to,ranges:[r]});n=o.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let o of Gc(t)){if(n?o.to==t.doc.length:o.from==0)continue;let c=t.doc.lineAt(n?o.to+1:o.from-1),u=c.length+1;if(n){r.push({from:o.to,to:c.to},{from:o.from,insert:c.text+t.lineBreak});for(let f of o.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:o.from},{from:o.to,insert:t.lineBreak+c.text});for(let f of o.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let o of Gc(t))n?r.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):r.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Gc(e).map(({from:s,to:o})=>(s>0?s--:o{let o;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(o=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,o)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),o;return r&&s&&r.to<=e&&s.from>=e&&(o=r.type.prop(yt.closedBy))&&o.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:o,to:c}=s,u=e.doc.lineAt(o),f=!t&&o==c&&qO(e,o);t&&(o=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new Uc(e,{simulateBreak:o,simulateDoubleBreak:!!f}),g=Yx(h,o);for(g==null&&(g=nc(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));cu.from&&o{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let o=t.changes(s);return{changes:s,range:ke.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Uc(t,{overrideIndentation:o=>{let c=n[o];return c??-1}}),s=Gh(t,(o,c,u)=>{let f=Yx(r,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let h=/^\s*/.exec(o.text)[0],g=zc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(qh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let o=nc(s,t.tabSize),c=0,u=zc(t,Math.max(0,o-Hc(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Kh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Yh}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Yh,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Yh,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Kh,shift:Kh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:aO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:o}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),o!==void 0&&(c["aria-expanded"]=String(o)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const zo=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:o=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,ae=J)=>{const he=O.current;if(!he)return;const we=he.state.doc.length,T=Math.max(0,Math.min(J,we)),z=Math.max(0,Math.min(ae,we));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const ae=O.current;if(!ae)return null;const he=Math.max(0,Math.min(J,ae.state.doc.length)),we=ae.coordsAtPos(he);return we?{left:we.left,right:we.right,top:we.top,bottom:we.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,ae=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Qa.highest(Xe.domEventHandlers({keydown:we=>(_.current?.(we),we.defaultPrevented)})),Xe.updateListener.of(we=>{we.docChanged&&!L.current&&j.current(we.state.doc.toString()),(we.selectionSet||we.docChanged)&&R.current?.(we.state.selection.main.head)})]}),he=new Xe({state:ae,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const ae=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(ae.anchor,e.length),head:Math.min(ae.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(o,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});zo.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Xh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(o,c)=>n(e.map((u,f)=>f===o?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((o,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:o.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:o.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:o.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||po(t),s=n==="dark",o=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Xh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(zo,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:o,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Xh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${o}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${o}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Xh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${o}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(zo,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(zo,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const o=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,o]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>o(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>o("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} -});`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;a{const u=a.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` +`).map(o=>{const u=o.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` `)}function Pv(t,e){return t.slice(0,Math.max(0,Math.min(e,t.length))).replace(/\r\n?/g,` `).length}function Yv(t,e,n){const r=t.split(` `),s=e.split(` -`),a=t.slice(0,Math.max(0,Math.min(n,t.length))),c=a.split(` -`).length-1,u=a.lastIndexOf(` -`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),o=t.slice(0,Math.max(0,Math.min(n,t.length))),c=o.split(` +`).length-1,u=o.lastIndexOf(` +`),f=o.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),o=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(o,s.length),selectionEnd:Math.min(Math.max(o,c),s.length)}}const Jh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Jh,"flex.collection":Jh,"flex.variables":Jh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,o)=>s.localeCompare(o)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,o]of r){const c=n.match(s);if(c)return{path:o,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function o3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function a3(t,e,n,r={},s=!1){const o=Math.max(0,Math.min(e,t.length)),c=t.slice(0,o),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:o-u.prefix.length,to:o,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:o-f.prefix.length,to:o,items:v}:null}const h=o3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:o-h.prefix.length,to:o,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:o-g.length,to:o,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:o={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,ae=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,ae))})},j=(B,K,ee=!1)=>{const be=a3(B,K,r,o,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(ao,{className:"h-3.5 w-3.5"}):p.jsx(Od,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(zo,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Xc="API-host execute route",Jc="the execute path";function Qc(t,e){return`${Xc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Qc("was unauthorized",`documentation authentication for ${Jc}`):t===403?Qc("was rejected",`CSRF, same-origin, and authorization middleware for ${Jc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Xc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Xc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Jc}.`:Qc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const o=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await o.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return o.status===429||o.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):o.redirected?Qc("was redirected",`authentication middleware for ${Jc}`):o.ok?`${Xc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(o.status,o.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Qh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Qh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Qh(n);if(!r)return t;const s=Qh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const o=new URL(t),c=`${o.pathname==="/"?"":o.pathname}${o.search}${o.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||po(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:o}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${o}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${o}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),o=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:o}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:o="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",ae=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",we=J||ae||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(ae),[qe,He]=I.useState(he),Je=I.useRef(we),$e=I.useRef(we),[ft,At]=I.useState(null),[bt,Ge]=I.useState(),[Q,re]=I.useState(null),[Se,Ne]=I.useState(null),[Be,We]=I.useState([]),[lt,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),ve=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Te=["GET","HEAD"].includes(Ae),je=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${je}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&o!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Fo=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=po(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Fo},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>o==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${le}-script-tab-${se}`,En=se=>`${le}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&o!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),ve.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Po=E?E(T.auth):T.auth,Qr=Pa({request:{...T,auth:Po},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),lu=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(ft,{...T,auth:Po},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ht(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Be.filter(se=>se.passed).length,Yo=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Yo&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${je}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||$e.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${je}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{ve.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Te&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:je,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:je,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(xf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:o==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>lu(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),o==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${je}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),o==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${je}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(bf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Yo,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(co,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),Se&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Se]}),ft&&p.jsx(QO,{response:ft,theme:s,curlCommand:bt,advanced:o==="advanced"}),Be.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Be.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Be.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),lt.length>0&&p.jsx(Rr,{code:lt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Wh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:o,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(o,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(o||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>hf(K),[K]),ae=t1(D,_)!==t1(w.request,A),he=C==="advanced",we=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Wh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(bf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${we}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&ae&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(La,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${we}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Wh("tab",ne)},onScriptTabChange:ne=>{B(ne),Wh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>pf(Ce,ne))})]})};function Wc(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(t){if(!t)return"";try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"?e.origin:""}catch{return""}}function T3(t,e,n,r){const s=e.startsWith("/")?e:`/${e}`;return{method:t.toUpperCase(),url:n?`${n}${s}`:s,auth:{type:"none"},...r?{hostExecution:{preferHostExecution:!0}}:{}}}function j3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function E3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const O3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:o,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=j3(),h=o??nf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L){if(!(c?.runtimeOnly?.some(lt=>lt.path===e&<.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(lt=>lt.code==="runtime.operation-undocumented"&<.location.path===e&<.location.method?.toUpperCase()===n.toUpperCase())))return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const Se=N3(c?.serverOrigin),Ne=s.tryIt?.hostExecution,Be=Ne?.available===!0&&Ne.preferHostExecution!==!1,We=()=>u?.({request:T3(n,e,Se,Be),serverUrl:Se||void 0,scripts:{preRequest:"",tests:""},requestTab:"params",scriptTab:"pre-request"});return p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsxs("dl",{className:`mt-4 space-y-3 text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:[p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.contractEvidence||"Contract"}),p.jsx("dd",{children:ce?.contractNotDeclared||"OpenAPI does not declare this operation."})]}),p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.runtimeEvidence||"Runtime"}),p.jsx("dd",{children:ce?.runtimeRouteUndocumented||`${n.toUpperCase()} ${e} is registered by the running service.`})]})]}),u&&p.jsxs("button",{type:"button",className:"mt-4 inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:We,children:[p.jsx(La,{className:"h-4 w-4"}),ce?.openApiClient||"Open in API Client"]})]})}if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",ae=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,we={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const Se=!A.has(re);w(Ne=>{const Be=new Set(Ne.key===b?Ne.sections:g);return Be.has(re)?Be.delete(re):Be.add(re),{key:b,sections:Be}}),re==="tryIt"&&E3("tryIt",Se?"1":void 0)},He=(re,Se,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Se}-heading`,children:[p.jsxs("button",{type:"button",id:`${Se}-heading`,"aria-expanded":A.has(Se),onClick:()=>qe(Se),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Se)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(Se)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},$e=(re,Se)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=ae.indexOf(Se),Be=re.key==="Home"?ae[0]:re.key==="End"?ae[ae.length-1]:re.key==="ArrowRight"?ae[(Ne+1)%ae.length]:ae[(Ne-1+ae.length)%ae.length];Je(Be)},ft=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wc(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,bt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{ft()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Cd,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&bt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:bt.map(([re,Se])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof Se=="string"?Se:JSON.stringify(Se)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...we})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,Se])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),Se.schema&&p.jsx(Dr,{spec:t,schema:Se.schema,theme:r,...we}),Se.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Se.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,Se])=>{const Ne=In.isReference(Se)?In.resolveReference(t,Se.$ref):Se;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([Be,We])=>{const lt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:Be}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...we})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),lt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(lt.value??lt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Be)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:ae.map(re=>p.jsx("button",{ref:Se=>{R.current[re]=Se},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:Se=>$e(Se,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function M3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function R3(t,e){let n=M3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function D3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const o of In.getHttpMethods(s)){const c=s[o];n.push({path:r,method:o,operation:c,score:R3(c,o),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const _3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",o=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=D3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:o,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${o}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${o}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${o}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${o}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${o}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${o}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(La,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(La,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${o}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${o}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const L3=typeof n1>"u"?{commit:"unknown"}:n1,q3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=L3,o=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),o]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},B3=(t,e,n)=>t==="dark"?n:e,$3="Runtime intelligence returned an invalid snapshot.",I3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),H3=new Set(["error","warning","info"]),z3=new Set(["pass","warn","fail","partial"]);function sn(){throw new Error($3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&sn(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&sn(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];sn()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&sn(),n}function U3(t){return Ji(t)||sn(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||sn(),t.map(U3)}function V3(t){(!Ji(t)||!Ji(t.location))&&sn();const e=Un(t,"code"),n=Un(t,"severity");(!I3.has(e)||!H3.has(n)||t.location.kind!=="operation")&&sn();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const o=i1(t,"expected");o!==void 0&&(r.expected=o);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),t.disposition!==void 0&&(t.disposition!=="acknowledged"&&sn(),r.disposition="acknowledged"),r}function F3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&sn();const e=Un(t,"status");z3.has(e)||sn();const n=t.findings.map(V3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&sn();const o=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==o&&sn(),{status:e,complete:t.complete,findings:n,summary:r}}function P3(t){Ji(t)||sn(),(!Ji(t.runtime)||!Ji(t.summary))&&sn(),typeof t.discoveryComplete!="boolean"&&sn();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const o=Zh(t,"serverOrigin");if(o&&(r.serverOrigin=o),t.server!==void 0){Ji(t.server)||sn();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&sn(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||sn(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=F3(t.validation)),r}const Y3=60;function K3(t,e,n=Y3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function G3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const X3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:o,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:o},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,o,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=K3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=G3(C.current);if(!J.length)return;const ae=J[0],he=J[J.length-1],we=document.activeElement;q.shiftKey&&(we===ae||!C.current.contains(we))?(q.preventDefault(),he.focus()):!q.shiftKey&&(we===he||!C.current.contains(we))&&(q.preventDefault(),ae.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},J3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function Q3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:o,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=W3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(o)?o.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:Q3(o),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(o)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),J3[D]]},D))]}),o!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function eM(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const tM=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:o,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),o();return}if(j.key!=="Tab"||!f.current)return;const R=eM(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,o]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:o}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:o,children:p.jsx(Md,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(nM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),o())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function nM({result:t,theme:e,messages:n,onSelect:r}){const o=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:o,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code}),u.disposition==="acknowledged"&&p.jsx("span",{children:n?.acknowledgedFinding||"acknowledged"})]}),p.jsx("div",{className:`mt-1 text-xs ${o}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${o}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${o}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:o,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>o?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>o(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function iM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Zc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function eu(t){return Array.isArray(t)?`[${t.map(eu).join(",")}]`:Zc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${eu(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function rM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function o1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){o1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function sM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function a1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let o=n?s.get(n):void 0;for(;o&&!r.has(o.id);)r.add(o.id),o=o.parentFolderId?s.get(o.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const o of t.folders)o.collectionId!==e||!o.parentFolderId||r.has(o.id)||r.has(o.parentFolderId)&&(r.add(o.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const o=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))o.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&o.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function lM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[sM(r)],activeEnvironmentId:r.id}}function oM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=a1(r,e),o=f1(r,e);h1(o,e);const c=lM(r,n.environmentId),u={version:6,collections:[rM(s)],folders:d1(r,e),requests:o,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function aM(t){if(!Zc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function tu(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function cM(t,e){const n=a1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(o=>o.id===e.folderId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(o=>o.id===e.requestId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function uM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function dM(t){if(!Zc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Zc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=aM(t.scope),n=uM(t.workspace),r=oy(n);if(eu(n)!==eu(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");tu(r.collections,"collection"),tu(r.folders,"folder"),tu(r.requests,"request"),tu(r.environments,"environment"),cM(r,e);for(const s of r.requests)o1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function fM(t){return`${JSON.stringify(dM(t),null,2)} +`}function hM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let o=!0;for(;o;){o=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),o=!0)}return s}function Sl(t,e,n){const r=hM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function pM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(o=>o.id===e)?.name||"Deleted collection";if(!n)return r;const s=pM(t.folders.filter(o=>o.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function mM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function gM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const o=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=pf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&mM(E);let j;E.result&&!D&&(s=ay(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(o.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=o.filter(g=>g.cancelled).length,h=o.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:o.length,passed:u,failed:h,cancelled:f,stopped:c,items:o,workspace:s}}function Gr(){return new Date().toISOString()}function yM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const bM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:o,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,Se=(Ne,Be)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:Be}),Se(We.id,Be+1))})};return Se(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),Se(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],Se=new Set;let Ne=K.get(Q);for(;Ne&&!Se.has(Ne.id);)Se.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const Se=oM(h,Q),Ne=new Blob([fM(Se)],{type:"application/json;charset=utf-8"}),Be=URL.createObjectURL(Ne),We=document.createElement("a");We.href=Be,We.download=yM(re),We.click(),setTimeout(()=>URL.revokeObjectURL(Be),0),L("")}catch(Se){L(Se instanceof Error?Se.message:String(Se))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),Se=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:Se,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(Se),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(Se=>({...Se,folders:Se.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},ae=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(Se=>Se.id===M.id?{...Se,variables:[...Se.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:Se)}))},he=(Q,re)=>{if(!M)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Be=>Be.id===M.id?{...Be,variables:Be.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:Se}:Be)}))},we=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter(Be=>Be.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),Se=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:Se,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(Se),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map(Be=>Be.id===j?{...Be,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:Be)}));return}const Se={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,Se]})),R(Se.id),O(Q)},me=Q=>{const re=h.requests.find(Se=>Se.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(Se=>Se.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(Se=>Se.id===Q);g(Se=>LC(Se,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",$e=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),ft=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=be(Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return p.jsxs(kd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Be}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${Be} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},Be),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(lt=>ft(lt,re+1,Ne))]},Q.id)},At=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=Y.filter(lt=>lt.folderId===Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return Be.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Be.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:Be.map($e)})]}),We.map(lt=>At(lt,re+1,Ne))]},Q.id)},bt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>o?.(Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(xf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:ae,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:Se=>he(Q.id,{enabled:Se.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:Se=>he(Q.id,{key:Se.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:Se=>he(Q.id,{value:Se.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>we(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),bt.map(Q=>ft(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(xf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map($e),bt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function Uo(){return new Date().toISOString()}const xM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),o=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=Uo(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!o)return;const w=Uo();e(A=>({...A,environments:A.environments.map(C=>C.id===o.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!o)return;const C=Uo();e(E=>({...E,environments:E.environments.map(D=>D.id===o.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),o&&p.jsx("button",{type:"button","aria-label":`Delete environment ${o.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,o.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),o&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:o.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[o.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),o.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function nu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function vM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",o=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,o,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=nu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function wM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),o=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:o,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const o=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=kd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` -`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${o}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:o,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${o}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":o,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":o}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${o}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${o}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function op(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function AM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=AM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,o)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${o}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const kM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:o,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:o||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>vM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>wM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},ae=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],we=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:ae,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=nu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[op(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:nu(ne)?"text-red-600":j,children:op(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:nu(B)?"text-red-600":j,children:op(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[we,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ot(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?ot(r.value):""}function CM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function ap(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=CM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const o=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return o("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){o("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return o("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){o("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(o("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const o=ot(r.key).trim();return o?[{id:An("variable"),key:o,value:ot(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function NM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(o=>t.includes(o));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function TM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(ot).join(` +`):ot(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,o)=>{const c=ot(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${o}]`,f=TM(s.script,`${u}.script`,n).trim();if(!f)return;const h=NM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function jM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function EM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(o=>{const c=o.indexOf("=");return{key:S1(c>=0?o.slice(0,c):o),value:S1(c>=0?o.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function OM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function MM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=ot(r.key).trim();s&&(n=n.replace(new RegExp(`:${MM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function RM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=OM(t.query),n=ot(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=ot(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(ot).join("."):ot(t.host),o=ot(t.port),c=Array.isArray(t.path)?t.path.map(ot).join("/"):ot(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${o?`:${o}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function DM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function _M(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function LM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function qM(t,e,n,r){const s=_M(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const o=ot(t.mode);if(o==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?ot(c.language):"";return{body:ot(t.raw),contentType:s||LM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(o==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:ot(u.key),value:ot(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(o==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=ot(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:ot(c.query),variables:u},contentType:s||"application/json"}}if(o==="formdata"){const c=Xr(t.formdata).map(f=>{const h=ot(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(ot).filter(Boolean).join(", "):ot(f.src);return{key:ot(f.key),value:h==="text"?ot(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(o==="file"){const c=mn(t.file)?ot(t.file.src):ot(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${o}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function BM(t,e,n,r,s,o,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=ot(f.method).trim().toUpperCase()||"GET",g=RM(f.url),b=DM(f.header),v=qM(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:ap(f.auth,{type:"inherit"},`${c}.auth`,u)},A=EM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:o,updatedAt:o}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=ot(e.name)||"Untitled",o=w1(e.event,`${r}.event`,t.warnings),c=jM(t.inheritedScripts,o);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:ap(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=BM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function $M(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=ot(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=ot(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),o=An("collection"),c={id:o,name:e,auth:ap(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:o,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function IM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=ot(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function HM(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:$M(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:IM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function zM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function UM(t,e){const n=zM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function VM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const FM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,o]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=HM(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?UM(M,G.result):VM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?o({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?o({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):o({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(ao,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function PM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e.folderId);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function YM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const KM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const ae=await gM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(we=>({...we,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(we=>({...we,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(ae.workspace),Y(he=>Object.fromEntries(C.map(we=>{const T=he[we.id]||{status:"pending"};return[we.id,T.status==="pending"&&ae.stopped?{status:"skipped"}:T]}))),M(ae),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(co,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(co,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,ae)=>{const he=G[J.id]||{status:"pending"},we=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=we?.status!==void 0&&we.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:ae+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:PM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(ao,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:YM(he)}),we?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",we.status]}),we?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(Nd,{className:"mr-1 inline h-3.5 w-3.5"}),we.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Vo(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function GM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return po(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function XM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:o="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=GM(t),Y=Sn(e),B=nl(),K=o===!1?{}:j1(o),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[ae,he]=I.useState(Y),[we,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[$e,ft]=I.useState({}),[At,bt]=I.useState(),[Ge,Q]=I.useState(B),[re,Se]=I.useState(B.collections[0]?.id),[Ne,Be]=I.useState(""),We=I.useRef(B.collections[0]?.id),lt=I.useRef(void 0),[ti,Tn]=I.useState(o===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(o===!1)return;let Me=!1;return hy(o).then(Ze=>{Me||(Q(Ze),Se(Ze.collections[0]?.id),Be(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[o]);const x=my(o,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>hf(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,ae),[ce,ae]),V=I.useMemo(()=>XM(ce,ae)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,ae,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),ve=I.useCallback(Me=>{Se(Me),Be("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},le=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),o!==!1&&Vo(o,{requestTab:Me}),C?.(Me)},Te=Me=>{qe(Me),o!==!1&&Vo(o,{scriptTab:Me}),E?.(Me)},je=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>pf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,lt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>ay(Ze,{...Me,collectionId:We.current,folderId:lt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Se(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Be(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),o!==!1&&Vo(o,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{Se(Me),Be(Ze||""),bt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{ft({entryId:Me,runId:Ze}),Je("history")},Fo=()=>ni(Me=>{const Ze=!Me;return o!==!1&&Vo(o,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Fo,children:ht?p.jsx(Ed,{className:"h-4 w-4"}):p.jsx(jd,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(bf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(FM,{onWorkspaceChange:Q,onSelectedCollectionChange:ve,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(xM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(bM,{request:ce,scripts:ae,onLoadRequest:Dt,onSelectedCollectionChange:ve,onSelectedFolderChange:Be,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),o!==!1&&Vo(o,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(kM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:$e.entryId,initialRunId:$e.runId,theme:kt},`${$e.runId||""}:${$e.entryId||""}`):He==="runner"&&At?p.jsx(KM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:we,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:je,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:le,onRequestTabChange:Ae,onScriptTabChange:Te,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function iu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function JM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,o]of Object.entries(t.paths))for(const c of In.getHttpMethods(o)){if(Wc(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function QM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${iu(n.padding.vertical)||"0"} ${iu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:iu(n.maxHeight)||"32px",maxWidth:iu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const WM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const o=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=ho(o),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:o,preferences:c})),ae=I.useRef(null),he=I.useRef(null),we=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===o?q.preferences:ho(o),Je=n&&He.theme||e,$e=Je==="high-contrast"?"dark":Je,ft=He.expand,At=He.expandedTags??["default"],bt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...JM($e,Ge),...r}),[$e,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return P3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const le=R1(t,window.location.hash);if(le){g(le);return}const Ae=window.location.hash.replace(/^#/,"");g(Te=>Te&&Ae&&Wc(Te.path,Te.method)===Ae?Te:null)},de=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const le=ae.current,Ae=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Te=je=>{if(je.key==="Escape"){je.preventDefault(),M(!1);return}if(je.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];je.shiftKey&&document.activeElement===ze?(je.preventDefault(),Ve.focus()):!je.shiftKey&&document.activeElement===Ve&&(je.preventDefault(),ze.focus())};return document.addEventListener("keydown",Te),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Te),de?.focus()}},[L]);const re=()=>{J({key:o,preferences:ho(o)})},Se=F=>{J(de=>{const le=de.key===o?de.preferences:ho(o);return{key:o,preferences:{...le,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>we.current?.scrollTo({top:0,behavior:"auto"})),Be=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wc(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},lt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!bt;Ba(o,"sidebarCollapsed",F),Se({sidebarCollapsed:F})},ht=nf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ft===void 0?ht:nf(ft),Vn=F=>{Ba(o,"expand",F),re()},qn=F=>{n&&(Ba(o,"theme",F),re())},kt=F=>{Ba(o,"expandedTags",F),Se({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=B3($e,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=$e==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=$e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),ve=p.jsx(pk,{spec:t,onEndpointSelect:Be,theme:$e,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.logo?p.jsx(QM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(iM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${bt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":bt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!bt&&ve}),p.jsxs("main",{ref:we,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(O3,{spec:t,path:h.path,method:h.method,theme:$e,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:lt}):p.jsx(_3,{spec:t,onEndpointSelect:Be,theme:$e}),p.jsx(q3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:$e,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:ae,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${$e==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:ve})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${$e==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(tM,{open:B&&T,theme:$e,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:Be,messages:X}),p.jsx(X3,{spec:t,theme:$e,messages:X,onEndpointSelect:Be,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>lt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Z3,{open:G,theme:$e,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:ft,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function ZM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function eR(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function tR(t,e){const n=e.load||ZM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),o={},c=new Map;async function u(g){if(g===r)return s;if(o[g])return o[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return o[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=eR(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(o).length&&(s[dp]=o),s}async function nR(t,e){return tR(t,e)}const ru="1",su=new WeakMap;function iR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=iR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},o=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!o.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function rR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function sR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=su.get(t);n&&n.unmount();const r=$A.createRoot(t);return su.set(t,r),r.render(e),()=>{su.get(t)===r&&su.delete(t),r.unmount()}}function $1(t,e,n){return sR(n),B1(t,p.jsx(WM,{spec:fp(e,n),theme:rR(n),options:n}))}function I1(t,e){const n={contractVersion:ru,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:ru,...e.options||{}},r=e.baseUri?await nR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:ru}),As.FLEXDOC_CONTRACT_VERSION=ru,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/go/assets/flexdoc.standalone.js b/adapters/go/assets/flexdoc.standalone.js index 3efc5433..bf78a4d9 100644 --- a/adapters/go/assets/flexdoc.standalone.js +++ b/adapters/go/assets/flexdoc.standalone.js @@ -1,86 +1,86 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(q,J){var oe=q.length;q.push(J);e:for(;0>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1>>1,we=q[he];if(0>>1;hes(me,ae))nes(Ce,me)?(q[he]=Ce,q[ne]=ae,he=ne):(q[he]=me,q[z]=ae,he=z);else if(nes(Ce,ae))q[he]=Ce,q[ne]=ae,he=ne;else break e}}return J}function s(q,J){var ae=q.sortIndex-J.sortIndex;return ae!==0?ae:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var we=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof we=="function"){b.callback=we,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=ae,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=ae,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,ae-he))):(q.sortIndex=we,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var ae=v;v=J;try{return q.apply(this,arguments)}finally{v=ae}}}})(vd)),vd}var Ng;function RA(){return Ng||(Ng=1,xd.exports=MA()),xd.exports}var wd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function($e){return $e})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ad.exports=_A(),Ad.exports}var Mg;function qA(){if(Mg)return oo;Mg=1;var t=RA(),e=Sd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1we||(i.current=he[we],he[we]=null,we--)}function me(i,l){we++,he[we]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function $e(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,a=Q2(l,i.type);l!==a&&(me(Ce,i),me(ne,a))}function ft(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oa._currentValue=ae)}var At,bt;function Ge(i){if(At===void 0)try{throw Error()}catch(a){var l=a.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",bt=-1)":-1m||$[d]!==te[m]){var fe=` -`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ge(a):""}function Se(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",a=null;do l+=Se(i,a),a=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var $e=Object.prototype.hasOwnProperty,We=t.unstable_scheduleCallback,vt=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ft=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,kt=t.unstable_NormalPriority,x=t.unstable_LowPriority,U=t.unstable_IdlePriority,pe=t.log,ue=t.unstable_setDisableYieldValue,X=null,k=null;function V(i){if(typeof pe=="function"&&ue(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var W=Math.clz32?Math.clz32:de,we=Math.log,F=Math.LN2;function de(i){return i>>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(ve(i)/F|0)|0}var le=256,Ae=262144,Te=4194304;function je(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,a){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=je(d):(S&=N,S!==0?m=je(S):a||(a=N&~i,a!==0&&(m=je(a))))):(N=d&~y,N!==0?m=je(N):S!==0?m=je(S):a||(a=d&~i,a!==0&&(m=je(a)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,a=l&-l,y>=a||y===32&&(a&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Te;return Te<<=1,(Te&62914560)===0&&(Te=4194304),i}function Fn(i){for(var l=[],a=0;31>a;a++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Fo(i,l,a,d,m,y){var S=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(a=S&~a;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var oR=/[\n"\\]/g;function vi(i){return i.replace(oR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,a,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):a!=null?gp(i,S,On(a)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,a,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}a=a!=null?""+On(a):"",l=l!=null?""+On(l):a,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,a){l==="number"&&ou(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Tl(i,l,a,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Go={};Object.defineProperty(Go,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Go,Go),window.removeEventListener("test",Go,Go)}catch{wp=!1}var es=null,Sp=null,cu=null;function Q1(){if(cu)return cu;var i,l=Sp,a=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Qo),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return LR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function BR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function $R(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),cu=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:a,offset:l-i};i=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=pw(a)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=ou(i.document);l instanceof i.HTMLIFrameElement;){try{var a=typeof l.contentWindow.location.href=="string"}catch{a=!1}if(a)i=l.contentWindow;else break;l=ou(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var YR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,ta=null,Rp=!1;function bw(i,l,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Rp||Rl==null||Rl!==ou(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),ta&&ea(ta,d)||(ta=d,d=nd(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|a<it?(dt=Ie,Ie=null):dt=Ie.sibling;var vt=ie(P,Ie,Z[it],ye);if(vt===null){Ie===null&&(Ie=dt);break}i&&Ie&&vt.alternate===null&&l(P,Ie),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt,Ie=dt}if(it===Z.length)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;itit?(dt=Ie,Ie=null):dt=Ie.sibling;var Ss=ie(P,Ie,vt.value,ye);if(Ss===null){Ie===null&&(Ie=dt);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),xt===null?Fe=Ss:xt.sibling=Ss,xt=Ss,Ie=dt}if(vt.done)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;!vt.done;it++,vt=Z.next())vt=xe(P,vt.value,ye),vt!==null&&(H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return pt&&gr(P,it),Fe}for(Ie=d(Ie);!vt.done;it++,vt=Z.next())vt=oe(Ie,P,it,vt.value,ye),vt!==null&&(i&&vt.alternate!==null&&Ie.delete(vt.key===null?it:vt.key),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return i&&Ie.forEach(function(fD){return l(P,fD)}),pt&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){a(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){a(P,H.sibling),ye=m(H,Z.props),oa(ye,Z),ye.return=P,P=ye;break e}a(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=xu(Z.type,Z.key,Z.props,null,P.mode,ye),oa(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){a(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{a(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,Nu(Z),ye);if(Z.$$typeof===j)return Et(P,H,Su(P,Z),ye);Tu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(a(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(a(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):a(P,H)}return function(P,H,Z,ye){try{la=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===ku)throw Ie;var xt=li(29,Ie,null,P.mode);return xt.lanes=ye,xt.return=P,xt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function os(i,l,a){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=bu(i),Cw(i,null,a),l}return yu(i,d,l,a),bu(i)}function aa(i,l,a){if(l=l.updateQueue,l!==null&&(l=l.shared,(a&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}function Zp(i,l){var a=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var m=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var S={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,a=a.next}while(a!==null);y===null?m=y=l:y=y.next=l}else m=y=l;a={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=l:i.next=l,a.lastBaseUpdate=l}var em=!1;function ca(){if(em){var i=zl;if(i!==null)throw i}}function ua(i,l,a,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,oe=ie!==N.lane;if(oe?(ut&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=a;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=m.callbacks,oe===null?m.callbacks=[ie]:oe.push(ie))}else oe={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=oe,$=xe):fe=fe.next=oe,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;oe=N,N=oe.next,oe.next=null,m.lastBaseUpdate=oe,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,a);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=t4($,d);ha(i,l,fe,di(i))}else ha(i,l,d,di(i))}catch(xe){ha(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function o4(){}function ym(i,l,a,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,ae,a===null?o4:function(){return AS(i),a(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ae},next:null};var a={};return l.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ha(i,l.next.queue,{},di())}function bm(){return yn(Oa)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function a4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var a=di();i=ls(a);var d=os(l,i,a);d!==null&&(Qn(d,l,a),aa(d,l,a)),l={cache:Kp()},i.payload=l;return}l=l.return}}function c4(i,l,a){var d=di();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bu(i)?TS(l,a):(a=qp(i,l,a,d),a!==null&&(Qn(a,i,d),jS(a,l,d)))}function NS(i,l,a){var d=di();ha(i,l,a,d)}function ha(i,l,a,d){var m={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,a);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return yu(i,l,m,0),Mt===null&&gu(),!1}catch{}if(a=qp(i,l,m,d),a!==null)return Qn(a,i,d),jS(a,l,d),!0}return!1}function xm(i,l,a,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Bu(i)){if(l)throw Error(r(479))}else l=qp(i,a,d,2),l!==null&&Qn(l,i,2)}function Bu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=Ou=!0;var a=i.pending;a===null?l.next=l:(l.next=a.next,a.next=l),i.pending=l}function jS(i,l,a){if((a&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}var pa={readContext:yn,use:Du,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};pa.useEffectEvent=zt;var ES={readContext:yn,use:Du,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,a){a=a!=null?a.concat([i]):null,Lu(4194308,4,gS.bind(null,l,i),a)},useLayoutEffect:function(i,l){return Lu(4194308,4,i,l)},useInsertionEffect:function(i,l){Lu(4,2,i,l)},useMemo:function(i,l){var a=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return a.memoizedState=[d,l],d},useReducer:function(i,l,a){var d=$n();if(a!==void 0){var m=a(l);if(Js){V(!0);try{a(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=c4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,a=NS.bind(null,nt,l);return l.dispatch=a,[i.memoizedState,a]},useDebugValue:mm,useDeferredValue:function(i,l){var a=$n();return gm(a,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,a){var d=nt,m=$n();if(pt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=l(),Mt===null)throw Error(r(349));(ut&127)!==0||Jw(d,l,a)}m.memoizedState=a;var y={value:a,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,a,l),null),a},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(pt){var a=Zi,d=Wi;a=(d&~(1<<32-W(d)-1)).toString(32)+a,l="_"+l+"R_"+a,a=Mu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,a),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,a=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,a)),i||is(l,!0)}else i=id(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(a=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),a!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else a=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return l.flags&256?(ai(l),l):(ai(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(ai(l),l):(ai(l),null)}return ai(l),(l.flags&128)!==0?(l.lanes=a,l):(a=d!==null,i=i!==null&&i.memoizedState!==null,a&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),a!==i&&a&&(l.child.flags|=8192),Uu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)ga(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Eu(i),y!==null){for(l.flags|=128,ga(d,!1),i=y.updateQueue,l.updateQueue=i,Uu(l,i),l.subtreeFlags=0,i=a,a=l.child;a!==null;)Nw(a,i),a=a.sibling;return me(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Ku&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304)}else{if(!m)if(i=Eu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Uu(l,i),ga(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Ku&&a!==536870912&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,a=Kt.current,me(Kt,m?a&1|2:a&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return ai(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(a&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),a=l.updateQueue,a!==null&&Uu(l,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==a&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),l.memoizedState.cache!==a&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function p4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ft(l),null;case 31:if(l.memoizedState!==null){if(ai(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(ai(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return ai(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:ft(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&ai(l);break;case 13:ai(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:ai(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function ya(i,l){try{var a=l.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var m=d.next;a=m;do{if((a.tag&i)===i){d=void 0;var y=a.create,S=a.inst;d=y(),S.destroy=d}a=a.next}while(a!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,a){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=a,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var a=i.stateNode;try{Fw(l,a)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,a){a.props=Qs(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(d){Nt(i,l,d)}}function ba(i,l){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof a=="function"?i.refCleanup=a(d):a.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var a=i.ref,d=i.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(m){Nt(i,l,m)}else a.current=null}function n2(i){var l=i.type,a=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,a){try{var d=i.stateNode;q4(d,i.type,a,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,l):(l=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,l.appendChild(i),a=a._reactRootContainer,a!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,a),i=i.sibling;i!==null;)qm(i,l,a),i=i.sibling}function Vu(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?a.insertBefore(i,l):a.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vu(i,l,a),i=i.sibling;i!==null;)Vu(i,l,a),i=i.sibling}function r2(i){var l=i.stateNode,a=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,a),l[_t]=i,l[Yt]=a}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,an=null;function m4(i,l){if(i=i.containerInfo,rg=ud,i=yw(i),Op(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var oe;xe!==a||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(oe=xe.firstChild)!==null;)ie=xe,xe=oe;for(;;){if(xe===i)break t;if(ie===a&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(oe=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=oe}a=N===-1||$===-1?null:{start:N,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(sg={focusedElem:i,selectionRange:a},ud=!1,an=l;an!==null;)if(l=an,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,an=i;else for(;an!==null;){switch(l=an,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a title"))),xn(y,d,a),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(a.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(oe.rangeCount!==1||oe.anchorNode!==P.node||oe.anchorOffset!==P.offset||oe.focusNode!==H.node||oe.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),oe.removeAllRanges(),Ye>Et?(oe.addRange(Z),oe.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),oe.addRange(Z))}}}}for(xe=[],oe=N;oe=oe.parentNode;)oe.nodeType===1&&xe.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Na?32:a,q.T=null,a=Fm,Fm=null;var y=ps,S=jr;if(ln=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,a),wt=N,ka(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,a){l=Si(a,l),l=Am(i.stateNode,l,2),i=os(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,a){if(i.tag===3)q2(i,i,a);else for(;l!==null;){if(l.tag===3){q2(l,i,a);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(a,i),a=BS(2),d=os(l,a,2),d!==null&&($S(a,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,a){var d=i.pingCache;if(d===null){d=i.pingCache=new b4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(a)||(Hm=!0,m.add(a),i=A4.bind(null,i,l,a),l.then(i,i))}function A4(i,l,a){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ut&a)===a&&(Ut===4||Ut===3&&(ut&62914560)===ut&&300>ht()-Yu?(wt&2)===0&&Zl(i,0):zm|=a,Ql===ut&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function k4(i){var l=i.memoizedState,a=0;l!==null&&(a=l.retryLane),B2(i,a)}function C4(i,l){var a=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(a=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,a)}function N4(i,l){return We(i,l)}var Zu=null,to=null,Xm=!1,ed=!1,Jm=!1,gs=0;function tr(i){i!==to&&i.next===null&&(to===null?Zu=to=i:to=to.next=i),ed=!0,Xm||(Xm=!0,j4())}function ka(i,l){if(!Jm&&ed){Jm=!0;do for(var a=!1,d=Zu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,z2(d,y))}else y=ut,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(a=!0,z2(d,y));d=d.next}while(a);Jm=!1}}function T4(){$2()}function $2(){ed=Xm=!1;var i=0;gs!==0&&$4()&&(i=gs);for(var l=ht(),a=null,d=Zu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,a===null?Zu=m:a.next=m,m===null&&(to=a)):(a=d,(i!==0||(y&3)!==0)&&(ed=!0)),d=m}ln!==0&&ln!==5||ka(i),gs!==0&&(gs=0)}function I2(i,l){for(var a=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function oA(i,l,a){var d=no;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof a=="string"&&(m+='[crossorigin="'+a+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:a,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function K4(i){Er.D(i),oA("dns-prefetch",i,null)}function G4(i,l){Er.C(i,l),oA("preconnect",i,l)}function X4(i,l,a){Er.L(i,l,a);var d=no;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&a&&a.imageSrcSet?(m+='[imagesrcset="'+vi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(m+='[imagesizes="'+vi(a.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=io(i);break;case"script":y=ro(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&a&&a.imageSrcSet?void 0:i,as:l},a),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(ja(y))||l==="script"&&d.querySelector(Ea(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function J4(i,l){Er.m(i,l);var a=no;if(a&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ro(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),a.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ea(y)))return}d=a.createElement("link"),xn(d,"link",i),Xt(d),a.head.appendChild(d)}}}function Q4(i,l,a){Er.S(i,l,a);var d=no;if(d&&i){var m=fr(d).hoistableStyles,y=io(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(ja(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},a),(a=ji.get(y))&&fg(i,a);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,sd(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function W4(i,l){Er.X(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Z4(i,l){Er.M(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function aA(i,l,a,d){var m=(m=Re.current)?rd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(l=io(a.href),a=fr(m).hoistableStyles,d=a.get(l),d||(d={type:"style",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=io(a.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(ja(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ji.set(i,a),y||eD(m,i,a,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=a.async,a=a.src,typeof a=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ro(a),a=fr(m).hoistableScripts,d=a.get(l),d||(d={type:"script",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function io(i){return'href="'+vi(i)+'"'}function ja(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function eD(i,l,a,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",a),Xt(l),i.head.appendChild(l))}function ro(i){return'[src="'+vi(i)+'"]'}function Ea(i){return"script[async]"+i}function uA(i,l,a){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(a.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),sd(d,a.precedence,i),l.instance=d;case"stylesheet":m=io(a.href);var y=i.querySelector(ja(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(a),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,sd(y,a.precedence,i),l.instance=y;case"script":return y=ro(a.src),(m=i.querySelector(Ea(y)))?(l.instance=m,Xt(m),m):(d=a,(m=ji.get(y))&&(d=b({},a),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,sd(d,a.precedence,i));return l.instance}function sd(i,l,a){for(var d=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function tD(i,l,a){if(a===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function nD(i,l,a,d){if(a.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var m=io(d.href),y=l.querySelector(ja(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=od.bind(i),l.then(i,i)),a.state.loading|=4,a.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),a.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,l),(l=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=od.bind(i),l.addEventListener("load",a),l.addEventListener("error",a))}}var pg=0;function iD(i,l){return i.stylesheets&&i.count===0&&cd(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function od(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ad=null;function cd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ad=new Map,l.forEach(rD,i),ad=null,od.call(i))}function rD(i,l){if(!(l.state.loading&4)){var a=ad.get(i);if(a)var d=a.get(null);else{a=new Map,ad.set(i,a);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),bd.exports=qA(),bd.exports}var $A=BA(),I=Sd();const kd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!o&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(o)?o:[o]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},o)=>I.createElement(VA,{ref:o,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _a=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Cd=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const ao=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Nd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Td=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const La=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const jd=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const Ed=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const co=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Od=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Md=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},qa={},Or={},Pg;function uo(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` -`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` -`,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` -`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentb&&(h=" ... ",o=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(o,c).replace(/\t/g,"→")+g,pos:u-o+h.length}}function n(s,o){return t.repeat(" ",o-s.length)+s}function r(s,o){if(o=Object.create(o||null),!s.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+o.linesAfter,f.length).toString().length,w=o.maxLength-(o.indent+v+3);for(let C=1;C<=o.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",o.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` +`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",o.indent)+n((s.line+1).toString(),v)+" | "+A.str+` +`,b+=t.repeat("-",o.indent+v+3+A.pos)+`^ +`;for(let C=1;C<=o.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",o.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Dd=r,Dd}var _d,Gg;function Mn(){if(Gg)return _d;Gg=1;const t=fo(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(o){const c={};return o!==null&&Object.keys(o).forEach(function(u){o[u].forEach(function(f){c[String(f)]=u})}),c}function s(o,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+o+'" YAML type.')}),this.options=c,this.tag=o,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return _d=s,_d}var Ld,Xg;function Jg(){if(Xg)return Ld;Xg=1;const t=fo(),e=Mn();function n(o,c){const u=[];return o[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(o.multi[u.kind].push(u),o.multi.fallback.push(u)):o[u.kind][u.tag]=o.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function o(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ud}var Vd,d0;function f0(){if(d0)return Vd;d0=1;const t=uo(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function o(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Vd=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:o,predicate:f,represent:u,defaultStyle:"lowercase"}),Vd}var Fd,h0;function p0(){return h0||(h0=1,Fd=r0().extend({implicit:[l0(),a0(),u0(),f0()]})),Fd}var Pd,m0;function g0(){return m0||(m0=1,Pd=p0()),Pd}var Yd,y0;function b0(){if(y0)return Yd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function o(c){return c.toISOString()}return Yd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:o}),Yd}var Kd,x0;function v0(){if(x0)return Kd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Kd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Kd}var Gd,w0;function S0(){if(w0)return Gd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function o(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Gd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:s}),Gd}var Xd,A0;function k0(){if(A0)return Xd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(o){if(o===null)return!0;const c={},u=o;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function ae(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function we(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function bt(x,U,pe){let ue,X,k,V,W,ve;const F=x.kind,de=x.result;let le=x.input.charCodeAt(x.position);if(R(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;le!==0;){if(le===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(le===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&ft(x)||pe&&_(le))break;if(O(le))if(V=x.line,W=x.lineStart,ve=x.lineIndent,$e(x,!1,-1),x.lineIndent>=U){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=ve;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))$e(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const ve=x.anchor;let F,de,le,Ae;const Te=Object.create(null);let je,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&ae(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if($e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=ve,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=je=ze=null,de=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=le=!0,x.position++,$e(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ht(x,U,o,!1,!0),Le=x.tag,je=x.result,$e(x,!0,U),Ve=x.input.charCodeAt(x.position),(le||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),$e(x,!0,U),ht(x,U,o,!1,!0),ze=x.result),Ae?He(x,W,Te,Le,je,ze,ue,X,k):de?W.push(He(x,null,Te,Le,je,ze,ue,X,k)):W.push(je),$e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function Se(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,ve=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` -`,de=we&&(k[k.length-2]===` +`,X?1+W:W),X=!0,k=!0,W=0;const le=x.position;for(;!O(de)&&de!==0;)de=x.input.charCodeAt(++x.position);Ce(x,le,x.position,!1)}return!0}function Ne(x,U){const pe=x.tag,ue=x.anchor,X=[];let k=!1;if(x.firstTabInLine!==-1)return!1;x.anchor!==null&&ae(x,x.anchor,X);let V=x.input.charCodeAt(x.position);for(;V!==0&&(x.firstTabInLine!==-1&&(x.position=x.firstTabInLine,q(x,"tab characters must not be used in indentation")),V===45);){const W=x.input.charCodeAt(x.position+1);if(!R(W))break;if(k=!0,x.position++,$e(x,!0,-1)&&x.lineIndent<=U){X.push(null),V=x.input.charCodeAt(x.position);continue}const ve=x.line;if(ht(x,U,u,!1,!0),X.push(x.result),$e(x,!0,-1),V=x.input.charCodeAt(x.position),(x.line===ve||x.lineIndent>U)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(je&&(X=x.line,k=x.lineStart,V=x.position),ht(x,U,f,!0,ue)&&(je?Ae=x.result:Te=x.result),je||(He(x,F,de,le,Ae,Te,X,k,V),le=Ae=Te=null),$e(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const je=k=V=f===pe||u===pe;if(ue&&$e(x,!0,-1)&&(ve=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&le.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&ae(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&($e(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if($e(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,$e(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),$e(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ft(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,$e(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==o||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==o&&k!==f&&k!==u}function He(k,V,W){const ve=qe(k),F=ve&&!Ce(k);return(W?ve:ve&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==o&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function $e(k){return!Ce(k)&&k!==j}function ft(k,V){const W=k.charCodeAt(V);let ve;return W>=55296&&W<=56319&&V+1=56320&&ve<=57343)?(W-55296)*1024+ve-56320+65536:W}function At(k){return/^\n* /.test(k)}const bt=1,Ge=2,Q=3,re=4,Se=5;function Ne(k,V,W,ve,F,de,le,Ae){let Te,je=0,Le=null,ze=!1,Ve=!1;const Dt=ve!==-1;let Fn=-1,jn=Je(ft(k,0))&&$e(ft(k,k.length-1));if(V||le)for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}else{for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),je===u)ze=!0,Dt&&(Ve=Ve||Te-Fn-1>ve&&k[Fn+1]!==" ",Fn=Te);else if(!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}Ve=Ve||Dt&&Te-Fn-1>ve&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!F(k)?bt:de===we?Se:Ge:W>9&&At(k)?Se:le?de===we?Se:Ge:Ve?re:Q}function Be(k,V,W,ve,F){k.dump=(function(){if(V.length===0)return k.quotingType===we?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===we?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=ve||k.flowLevel>-1&&W>=k.flowLevel;function Te(je){return ne(k,je)}switch(Ne(V,Ae,k.indent,le,Te,k.quotingType,k.forceQuotes&&!ve,F)){case bt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+lt(z(V,de));case re:return">"+We(V,k.indent)+lt(z(ti(V,le),de));case Se:return'"'+ht(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",ve=k[k.length-1]===` +`,de=ve&&(k[k.length-2]===` `||k===` -`)?"+":we?"":"-";return W+de+` -`}function vt(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`)?"+":ve?"":"-";return W+de+` +`}function lt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let ve=(function(){let Ae=k.indexOf(` `);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` -`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` -`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` -`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` -`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` -`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ -`)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); -const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` -`)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` -`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`||k[0]===" ",de,le;for(;le=W.exec(k);){const Ae=le[1],Te=le[2];de=Te[0]===" ",ve+=Ae+(!F&&!de&&Te!==""?` +`:"")+Tn(Te,V),F=de}return ve}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let ve,F=0,de,le=0,Ae=0,Te="";for(;ve=W.exec(k);)Ae=ve.index,Ae-F>V&&(de=le>F?le:Ae,Te+=` +`+k.slice(F,de),F=de+1),le=Ae;return Te+=` +`,k.length-F>V&&le>F?Te+=k.slice(F,le)+` +`+k.slice(le+1):Te+=k.slice(F),Te.slice(1)}function ht(k){let V="",W=0;for(let ve=0;ve=65536?ve+=2:ve++){W=ft(k,ve);const F=ce[W];!F&&Re(W)?(V+=k[ve],W>=65536&&(V+=k[ve+1])):V+=F||ae(W)}return V}function ni(k,V,W){let ve="";const F=k.tag;for(let de=0,le=W.length;de"u"&&U(k,V,null,!1,!1))&&(ve!==""&&(ve+=","+(k.condenseFlow?"":" ")),ve+=k.dump)}k.tag=F,k.dump="["+ve+"]"}function Vn(k,V,W,ve){let F="";const de=k.tag;for(let le=0,Ae=W.length;le"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!ve||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let ve="";const F=k.tag,de=Object.keys(W);for(let le=0,Ae=de.length;le1024&&(Te+="? "),Te+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Te+=k.dump,ve+=Te))}k.tag=F,k.dump="{"+ve+"}"}function kt(k,V,W,ve){let F="";const de=k.tag,le=Object.keys(W);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Te=le.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?je+="?":je+="? "),je+=k.dump,Ve&&(je+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?je+=":":je+=": ",je+=k.dump,F+=je)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const ve=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=ve.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Te}return!0}}return!1}function U(k,V,W,ve,F,de,le){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Te=ve;ve&&(ve=k.flowLevel<0||k.flowLevel>V);const je=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(je&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(je&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")ve&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")ve&&k.dump.length!==0?(k.noArrayIndent&&!le&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&Be(k,k.dump,V,de,Te);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],ve=[];ue(k,W,ve);const F=ve.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const o of r){if(s===null||typeof s!="object"||!(o in s))throw new Error(`Reference not found: ${n}`);s=s[o]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const o=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return o[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:o,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),o?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],tf={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(tf),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function nf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...tf[t]]:Cs.filter(n=>t.some(r=>r===n||tf[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function ho(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(o=>typeof o=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function Ba(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const o={...ho(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete o[e]:o[e]=c,o.expand===void 0&&o.sidebarCollapsed===void 0&&o.theme===void 0&&o.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(o))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],o=e[r]??s?.default;if(o===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(o))throw new Error(`Invalid value for server variable ${r}: ${o}`);return o})}function rf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const o=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of o)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return rf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=rf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const o=r.requestBody,c=o?Object.keys(o.content||{})[0]:void 0;if(c){s.contentType=c;const u=o.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function sf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=sf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,o])=>`${s}=${cn(o)}`).join(","):r.flatMap(([s,o])=>[s,cn(o)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=sf(e),o=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(o);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[o(f),o(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=o(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=sf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([o,c])=>[`${t.name}[${o}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(o=>[t.name,cn(o)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const o=Object.entries(s);return r?o.map(([c,u])=>[c,cn(u)]):[[t.name,o.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,o){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,o))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=o[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=rf(t,e,n),o=s.servers[0],c=r.serverUrl||(o?wk(o,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const o=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)o.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&o.push(` --data-raw ${un(t.body)}`),o.join(` \\ +`)}if(e==="javascript"){const o={method:t.method};return n.length&&(o.headers=t.headers),t.body&&(o.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(o,null,2)}); +const data = await response.json();`}if(e==="python"){const o=["import requests","",`url = ${un(t.url)}`];return n.length&&o.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&o.push(`body = ${un(t.body)}`),o.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),o.join(` +`)}if(e==="go"){const o=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${o})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` +`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[o,c]of n)r.push(` .header(${un(o)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var lf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,o=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=ae.value.length,ae=ae.next){var we=ae.value;if(j.length>O.length)return;if(!(we instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=ae.value.length;Re>=ne;)ae=ae.next,ne+=ae.value.length;if(ne-=ae.value.length,he=ne,ae.value instanceof f)continue;for(var Ce=ae;Ce!==j.tail&&(neM.reach&&(M.reach=$e);var ft=ae.prev;He&&(ft=v(j,ft,He),he+=He.length),w(j,ft,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(ae=v(j,ft,At),Je&&v(j,ae,Je),T>1){var bt={cause:G+","+B,reach:$e};g(O,j,R,ae.prev,he,bt),M&&bt.reach>M.reach&&(M.reach=bt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+o+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(o),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:o=!1})=>{const[c,u]=kd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${o?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:o=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(o.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(o);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:o})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:o},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:o})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:o})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function $a(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),o=Object.keys(r);return s.length===o.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function of(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const o=e(),c=of(o,r),u={key:r,value:String(s),enabled:!0};c>=0?o[c]=u:o.push(u)};return{get(r){const s=of(e(),r);return s>=0?e()[s].value:void 0},has(r){return of(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=$a(t.variables||{}),r=$a(t.collectionVariables||{}),s=$a(t.externalVariables||{}),o=$a(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(o,R)?n[R]=o[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return o[R]},has(R){return Object.prototype.hasOwnProperty.call(o,R)},set(R,_){const L=String(_);o[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete o[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(o,M)?o[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` -`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!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:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,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}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{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 n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.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 fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(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(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(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}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(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,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}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 n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` -`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;se.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",o=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${o}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const o=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>o.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:o}}function cf(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function Ia(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&Ia(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&Ia(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&Ia(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&Ia(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const o=Y0(n);if(o.length>0)throw new Error(`This request requires API host execution (${o.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=cf(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,o])=>({key:s,value:o})),body:t.body,contentType:cf(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:cf(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,o])=>({key:s,value:o,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function po(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const o=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return o&&!("$ref"in o)?o:void 0}function lC(t,e,n,r){const o=rC(t,e,n)?.security??t.security??[];if(!o.length)return;const c=o.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=o.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(o.find(f=>Object.keys(f).length===0)??o[0])}function oC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,o=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:o?.authorizationUrl,tokenUrl:o?.tokenUrl,scopes:n.length?n:Object.keys(o?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function aC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let o=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return o;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return o;if(!h)return{...o,auth:{type:"inherit"}};const g=oC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?o=X0(o,"Authorization"):g.type==="apiKey"&&g.in==="header"?o=X0(o,g.key):g.type==="apiKey"&&g.in==="query"&&(o=aC(o,g.key)),{...o,auth:g}):o}function uC(t,e,n,r,s){const o=B0(t,e,n,r);return{request:cC(t,e,n,r,o),serverUrl:r.serverUrl||s}}function Ha(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const uf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function df(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>df(e.key)?{...e,value:uf}:e)}function fC(t){return t?.map(e=>df(e[0])?[e[0],uf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const o=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return df(g)?`${h}=${encodeURIComponent(uf)}`:u}).join("&");return`${o}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Ha(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",o={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete o.responseBody,delete o.responseBodyTruncated,delete o.requestBodyTruncated),o});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Ha(n.auth)})),folders:t.folders.map(n=>({...n,auth:Ha(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Ha(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function mo(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function za(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function Ua(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!Ua(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Va(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function ff(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(ff(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Va(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(ff(t),JSON.stringify(wC(e))):sessionStorage.removeItem(ff(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(Ua))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(Ua))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(Ua))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Va(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Va(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Va(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const o=r.get(s.parentFolderId);(!o||o.collectionId!==s.collectionId||o.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const o=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(o.has(c)){s.parentFolderId=void 0;break}o.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!za(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!za(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!za(t,"runIndex")||!za(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,o])=>[s,o]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=mo();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function oy(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),o=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:o,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:o,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=o=>{if(o.length<=e)return e-=o.length,o;const c=o.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(o=>({...o,value:r(o.value)}))),s.formData&&(s.formData=s.formData.map(o=>({...o,value:r(o.value)}))),{request:s,truncated:n}}function ay(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),o={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:mo()};return{...t,history:[o,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),o=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!o.has(c.id);){if(o.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function hf(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function pf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),o=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,o=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});o=!0}if(!o)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:mo()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let o=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=o.filter(w=>w.key.trim()!==h);v.length!==o.length&&(o=v,c=!0);continue}const g=o.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];o[v]={...o[v],key:h,value:b,enabled:!0},g.length>1&&(o=o.filter((w,A)=>A===v||w.key.trim()!==h))}else o.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:o,updatedAt:mo()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=mo();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const o=e.transaction(tl,"readonly").objectStore(tl).get(t);o.onsuccess=()=>n(AC(t,oy(o.result))),o.onerror=()=>r(o.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const o=n.transaction(tl,"readwrite");o.objectStore(tl).put(Z0(e),t),o.oncomplete=()=>r(),o.onerror=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace")),o.onabort=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),o=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{o.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,o.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function mf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,o=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:mf(O,.5),p95Ms:mf(O,.95),p99Ms:mf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),o=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:o===null?null:new Date(o).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,o=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const gf=zC();function VC(t){gf.record(t)}function FC(){return gf.snapshot()}function PC(){gf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function yf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=yf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Fa(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,o]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${o}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Pa(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&po(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,o=t.hostExecution?.preferHostExecution,c=o===!1?!1:t.preferHostExecution??s??o??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Pa({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:o}of n){const c=s.file;r.append(`formData[${o}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=yf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let o=yf(t.request),c=Fa(t.variables),u=Fa(t.collectionVariables);const f=Fa(t.externalVariables);let h=Fa(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(o=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(o={...o,auth:t.resolveAuth(o.auth)}),o=nC(o,c),w=(o.method||"GET").toUpperCase(),A=o.url;const[j,,,R]=Pa({request:o,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(o);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(o);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function bf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:o="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":o,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Ya(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const o of e)n+=String.fromCharCode(o);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function oN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),o=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",o),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Ya(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function aN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||aN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const o=vy(48),c=await oN(o);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:o}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,o=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:o,scope:typeof n.scope=="string"?n.scope:void 0}}async function Ka(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},o=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&o?s.Authorization=`Basic ${lN(`${o}:${t.clientSecret||""}`)}`:(o&&e.set("client_id",o),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),o=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-osetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}const s=await cN(t,e.windowObject),o=await dN(s,e);if((o.searchParams.get("state")||new URLSearchParams(o.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(o.hash.replace(/^#/,"")),f=o.searchParams.get("error")||u.get("error");if(f){const b=o.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=o.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Ka(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Ya(t);return s&&r.set("scope",s),Ka(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,o]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{o(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{o(!1)}},w=async()=>{o(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{o(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},xf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:o,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>o(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>o({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:o}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>o({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>o({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>o({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>o({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>o({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>o({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>o({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>o({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>o({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>o({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>o({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>o({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>o({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>o({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>o({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>o({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>o({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>o({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let vf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=wf(t,e);for(e+=jy(r);e=0&&Ay(wf(t,c));)o++,c-=2;if(o%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new go(this),o=new go(e);for(let c=n,u=n;;){if(s.next(c),o.next(c),c=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new go(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.text[o],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let o=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ga(o.text,c.text.slice(),0,o.length);if(u.length<=32)r.push(new Vt(u,c.length+o.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ga(this.text,Ga(r.text,Ey(this.text,0,e)),n),o=this.length+r.length-(n-e);return s.length<=32?new Vt(s,o):Hi.from(Vt.split(s,[]),o)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;o<=n&&ce&&c&&(s+=r),eo&&(s+=u.slice(Math.max(0,e-o),n-o)),o=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let o of e)r.push(o),s+=o.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.children[o],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let o=0,c=0;c<=n&&o=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=o&&n<=u){let f=c.replace(e-o,n-o,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;oe&&o&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,o,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,o+=n){if(s==c||o==u)return r;let f=this.children[s],h=e.children[o];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),o=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>o&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ga(t,e,n=0,r=1e9){for(let s=0,o=0,c=!0;o=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],o=this.offsets[r],c=o>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new go(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},go.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const Sf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return o+(e-s);o+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?o:o+f;o+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Af(this,(n,r,s,o,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return kf(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,o=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,o.text),o.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],o=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||Sf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(o,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,o,g,b),s=h,o=g}}}function kf(t,e,n,r=!1){let s=[],o=r?[]:null,c=new yo(t),u=new yo(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),o.forward2(f),c.forward(f)}}}}class yo{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-o.from),n=e.indexOf(r);for(let s=1;so.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Cf=0;class Ue{constructor(e,n,r,s,o){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=Cf++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Nf),!!e.static,e.enables)}of(e){return new Xa([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Nf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Xa{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=Cf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,o=this.id,c=e[o]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Tf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[o];if(A!=null){let C=Za(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),o=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Ja).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let o=r.values[n],c=this.updateF(o,s);return this.compareF(o,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let o=r.facet(Ja),c=s.facet(Ja),u;return(u=o.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Ja.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function bo(t){return e=>new Ly(e,t)}const Qa={highest:bo(Ns.highest),high:bo(Ns.high),default:bo(Ns.default),low:bo(Ns.low),lowest:bo(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new jf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Wa{constructor(e,n,r,s,o,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=o,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],o=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(o[v.facet.id]||(o[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in o){let w=o[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Nf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Wa(e,c,b,u,f,o)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function o(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof jf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)o(h,u);else if(c instanceof jf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),o(h,u)}else if(c instanceof Ly)o(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&o(c.provides,u);else if(c instanceof Xa)r[u].push(c),c.facet.extensions&&o(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(h,u)}}return o(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function xo(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Za(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),Ef=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let o=s.map(n);o&&r.push(o)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,o,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=o,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),o.some(u=>u.type==rn.time)||(this.annotations=o.concat(rn.time.of(Date.now())))}static create(e,n,r,s,o,c){return new rn(e,n,r,s,o,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let o,c;if(r=t[r]))o=t[r++],c=t[r++];else if(s=0;s--){let o=r[s](t);o instanceof rn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof rn?t=o[0]:t=Vy(e,sl(o),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let o=n[s](t);o&&Object.keys(o).length&&(r=Uy(r,Of(e,o,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Mf;try{Mf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Mf)return Mf.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,o,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let o;n?o=e.startState.values.slice():(n=Wa.resolve(r,s,this),o=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(Ef)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),o=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Wa.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||Sf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(Ef)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(o,c)=>c.create(o),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>n.length?r:n[o-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let o of this.facet(qy))for(let c of o(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(o(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Rf(t,e,n={}){let r={};for(let s of t)for(let o of Object.keys(s)){let c=s[o],u=r[o];if(u===void 0)r[o]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,o))r[o]=n[o](u,c);else throw new Error("Config merge conflict for field "+o)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return _f.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Df(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let _f=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function Lf(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class qf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let o=r?this.to:this.from;for(let c=s,u=o.length;;){if(c==u)return c;let f=c+u>>1,h=o[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let o=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,o);oE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}o(C,E,v)}}return{mapped:c.length?new qf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:o=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(Lf)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new vo;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new vo),o.addRange(f,h,g,!1)};for(let f=0;f=o&&e<=o+c.length&&c.between(o,e-o,n-o,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return wo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return wo.from(e).goto(n)}static compare(e,n,r,s,o=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),f=Fy(c,u,r),h=new So(c,f,o),g=new So(u,f,o);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let o=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(o.length!=c.length)return!1;if(!o.length)return!0;let u=Fy(o,c),f=new So(o,u,0).goto(r),h=new So(c,u,0).goto(r);for(;;){if(f.to!=h.to||!$f(f.active,h.active)||f.point&&(!h.point||!Df(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,o=-1){let c=new So(e,null,o).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new vo;for(let s of e instanceof _f?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(Lf);e=r}return t}mt.empty.nextLayer=mt.empty;class vo{finishChunk(e){this.chunks.push(new qf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new vo)).addRange(e,n,r,s)}addInner(e,n,r,s){let o=e-this.lastTo||r.startSide-this.last.endSide;if(s&&o<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let o of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,o));return s.length==1?s[0]:new wo(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),Bf(this.heap,0)}}}function Bf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class So{constructor(e,n,r){this.minPoint=r,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=wo.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){ec(this.active,e),ec(this.activeTo,e),ec(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:o}=this.cursor;for(;n0;)n++;tc(this.active,n,r),tc(this.activeTo,n,s),tc(this.activeRank,n,o),e&&tc(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&ec(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,o){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!o.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Df(t.point,n.point)&&$f(t.activeForPoint(t.to),n.activeForPoint(n.to))||o.comparePoint(u,A,t.point,n.point),g=!1):(g&&o.boundChange(u),A>u&&!$f(t.active,n.active)&&o.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function $f(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;o+=t.charCodeAt(s)==9?n-o%n:1,s=kn(t,s)}return t.length}const If="ͼ",Gy=typeof Symbol>"u"?"__"+If:Symbol.for(If),Hf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ol{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function o(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))o(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");o(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)o(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,If+e.toString(36)}static mount(e,n,r){let s=e[Hf],o=r&&r.nonce;s?o&&s.setNonce(o):s=new IN(e,o),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let o=Jy.get(r);if(o)return e[Hf]=o;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Hf]=this}mount(e,n){let r=this.sheet,s=0,o=0;for(let c=0;c-1&&(this.modules.splice(f,1),o--,f=-1),f==-1){if(this.modules.splice(o++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Ao[dn]=String.fromCharCode(dn);for(var zf in $r)Ao.hasOwnProperty(zf)||(Ao[zf]=$r[zf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ao:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Uf=typeof document<"u"?document:{documentElement:{style:{}}};const Vf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Ff=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),ic=!!(Qy||Ff||Vf),Wy=!ic&&/gecko\/(\d+)/i.test(Dn.userAgent),Pf=!ic&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in Uf.documentElement.style,Yf=!ic&&/Apple Computer/.test(Dn.vendor),eb=Yf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:ic,ie_version:Qy?Uf.documentMode||6:Ff?+Ff[1]:Vf?+Vf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Pf,chrome_version:Pf?+Pf[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Yf,safari_version:Yf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:Uf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Kf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const rc=Object.create(null);function Gf(t,e,n){if(t==e)return!0;t||(t=rc),e||(e=rc);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let o of r)if(o!=n&&(s.indexOf(o)==-1||t[o]!==e[o]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:o,end:c}=nb(e,n);r=(o?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new Co(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}on.none=mt.empty;class ko extends on{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Kf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||rc}eq(e){return this==e||e instanceof ko&&this.tagName==e.tagName&&Gf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}ko.prototype.point=!1;class Co extends on{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Co&&this.spec.class==e.spec.class&&Gf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Co.prototype.mapMode=Wn.TrackBefore,Co.prototype.point=!0;class js extends on{constructor(e,n,r,s,o,c){super(n,r,o,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function al(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class No extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof No&&this.tagName==e.tagName&&Gf(this.attributes,e.attributes)}static create(e){return new No(e.tagName,e.attributes||rc,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}No.prototype.startSide=No.prototype.endSide=-1;function To(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Xf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function jo(t,e){if(!e.anchorNode)return!1;try{return Xf(t,e.anchorNode)}catch{return!1}}function lc(t){return t.nodeType==3?Oo(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Eo(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function oc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,o,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+o)):e.right>v.right-o&&(E=e.right-v.right+o,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let o=t.parentNode;o&&!(o==n.body||(!e||r)&&s);)if(o.nodeType==1)!s&&o.scrollHeight>o.clientHeight&&(s=o),e&&!r&&o.scrollWidth>o.clientWidth&&(r=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:r,y:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ob(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ab(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ob(e))}let cb;function Oo(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),o.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!oc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(o<0||(s!=0?s<0?u.fromn:e[o].level>u.level))&&(o=c)}}if(o<0)throw new RangeError("Index out of range");return o}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?o:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,o=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else o=h,f++}}}function Wf(t,e,n,r,s,o,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Zf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Wf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>o[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==o[h-1].to){if(b)break e;let C=o[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&o[D-1].to==E)E=o[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Zf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var o;let c=r.head-t.from,u=Vi.find(e,c,(o=r.bidiLevel)!==null&&o!==void 0?o:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,o,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=o,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const cc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(uc.of(h=>{let g=h.plugin(u);return g?c(g):on.none})),o&&f.push(o(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class ih{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),rh=Ue.define(),uc=Ue.define(),Eb=Ue.define(),sh=Ue.define(),Mo=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(o=>o instanceof Function?o(t):o),s=[];return mt.spans(r,e.from,e.to,{point(){},span(o,c,u,f){let h=o-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let o of t.state.facet(Rb)){let c=o(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ro=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(o,c,u,f))),this.changedRanges=s}static create(e,n,r){return new dc(e,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}}const oT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return oT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 hc)return e;return null}static get(e){return e.cmTile}}class fc extends Ht{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 n=this.dom,r=null,s,o=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,o&&s!=u.dom&&(o.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,o&&s&&(o.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hc extends fc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,o=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&o++,s=n.pop()}else{let c=r.children[s++];if(c instanceof or)n.push(s),r=c,s=0;else{let u=o+c.length,f=e(c,o);if(f!==void 0)return f;o=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,o,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,c=e-f)}}),!r&&!o)throw new Error("No tile at position "+e);return r&&n<0||!o?{tile:r,offset:s}:{tile:o,offset:c}}}class or extends fc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new or(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends fc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,o=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,o=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?o:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):aT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:o}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,o)):s.domPosFor(o,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function aT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=lc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let o=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(o--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let o=this.dom.getClientRects(),c=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;c=o[f],!(e>0?f==0:f==o.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:o,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(o==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:o}=u.pop(),o++}else{let f=s.children[o],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(lh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(lh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let o=Ht.get(e.text);o&&this.cache.reused.set(o,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let o=this.ensureMarks(n,r);!s&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let o=e.length-1;o>=0;o--){let c=e[o],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(oh,0,32)||new Rs(oh.toDOM(),0,oh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(o),n=o}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(pc,void 0,1);return r&&(r.flags=n),r||new pc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:o,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return o?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const mc=[Rs,fl,Ms,Hn,pc,or,hc];for(let t=0;t[]),this.index=mc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,o=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,o=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,o+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=o=0):c instanceof Hn&&(s.shift(),o=Math.min(o,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,o=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>o),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let o=Ht.get(s);if(s==this.view.contentDOM)break;o instanceof Hn?n.push(o):o?.isLine()?r=o:o instanceof or||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new ko({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Kf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function lh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends sc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const oh=new class extends sc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=on.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 hc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let o=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Oe.ie||Oe.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),o&&!r.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(r=o.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 o=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||r.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&jo(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(o||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!Eo(h.node,h.offset,b.anchorNode,b.anchorOffset)||!Eo(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=To(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=To(e.root),{anchorNode:s,anchorOffset:o}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,o)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let o;if(e==r.dom)o=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?o=e:o=e.nextSibling}if(o==r.dom.firstChild)return s;for(;o&&!Ht.get(o);)o=o.nextSibling;if(!o)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,o=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(o=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,o=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(o&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:o}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof ch?null:s.coordsInWidget(o,n,!0):s.coordsIn(o,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(o,c){if(o.isComposite())for(let u of o.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(o.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof or)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?lc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=o,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=lc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,o;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=lc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,o=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:o}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let o=s==n.viewports.length?null:n.viewports[s],c=o?o.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(on.replace({widget:new ch(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!o)break;r=o.to+1}return on.set(e)}updateDeco(){let e=1,n=this.view.state.facet(uc).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),r=!1,s=this.view.state.facet(sh).map((o,c)=>{let u=typeof o=="function";return u&&(r=!0),u?o(this.view):o});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Db(this.view),c={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),o=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=r,!o)return null;let c=e-o.offset;return{from:c,to:c+o.node.nodeValue.length,node:o.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:o,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(o),f.mapPos(c),o,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class ch extends sc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(s.length==0)return ke.cursor(e);o==0?n=1:o==s.length&&(n=-1);let c=o,u=o;n<0?c=kn(s.text,o,!1):u=kn(s.text,o);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);o+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,o,t.state.tabSize)}function uh(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let o of r.type){if(o.from>e)break;if(!(o.toe)return o;(!s||o.type==fn.Text&&(s.type!=o.type||(n<0?o.frome)))&&(s=o)}}return s||r}return r}function OT(t,e,n,r){let s=uh(t,e.head,e.assoc||-1),o=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(o){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(o.top+o.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,o,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),o=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return o=>{let c=r(o);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,o=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=o<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(o<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*o,E=fh(t,{x:b,y:C},!1,o);if(n?C>f.bottom:Cu:O{if(e>o&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+o:v.bottom>=f+o))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=o&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let o=0;o{let c=r[o]-n,u=r[o+1]-n;return Oo(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Oo(f.dom,0,f.length)).getClientRects()}),o=e.children[s.i],c=r[s.i];return o.isText()?this.scanText(o,c):o.isComposite()?this.scanTile(o,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let o=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:oc(s))||oc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>o)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,c=1,u;if(this.lineSeparator?(o=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(o=u.index,c=u[0].length),this.append(n.slice(r,o<0?n.length:o)),o<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=o+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:o,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=o||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!Xf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Xf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,o=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,o=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:o,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,o=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=o.from,g=null;(c===8||Oe.android&&e.text.length=u&&o.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&b.slice(o.to-u)==e.text.slice(v=e.text.length-(b.length-(o.to-u)))?n={from:o.from,to:o.to,insert:gt.of(e.text.slice(o.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||gc(r,o))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(o.from).toDate.now()-50?n={from:o.from,to:o.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:o.from,to:o.to,insert:gt.of([" "])}),n)return hh(t,n,r,c);if(r&&!gc(r,o)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Mo).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function hh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,o,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,o=s.selection.main,c=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=o.frome.to?s.sliceDoc(e.to,o.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(o.head);let w=o.to-e.to;r=s.changeByRange(A=>{if(A.from==o.from&&A.to==o.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-o.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),o=0;for(;o0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,o-Math.min(c,u));n-=c+f-o}if(c=c?o-n:0;o-=f,u=o+(u-c),c=o}else if(u=u?o-n:0;o-=f,c=o+(c-u),u=o}return{from:o,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||o!=r)&&e.push(new zb(s,o))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function gc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let o in n)if(o!="scroll"){let c=!n[o].handlers.length,u=r[o];u&&c!=!u.handlers.length&&(s.removeEventListener(o,this.handleEvent),u=null),u||s.addEventListener(o,this.handleEvent,{passive:c})}for(let o in r)o!="scroll"&&!n[o]&&s.removeEventListener(o,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,o=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],yc=6;function bc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Mo).map(c=>c(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,o=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+yc?n=-bc(s-e.clientX):e.clientX+f.right>=c-yc&&(n=bc(e.clientX-c)),e.clientY-f.top<=o+yc?r=-bc(o-e.clientY):e.clientY+f.bottom>=u-yc&&(r=bc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=To(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function xc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=xc(t.state,th,e);let{state:n}=t,r,s=1,o=n.toText(e),c=o.lines==n.selection.ranges.length;if(ph!=null&&n.selection.ranges.every(f=>f.empty)&&ph==o.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?o.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=o.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(o);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ab(t.contentDOM);let o=t.root.activeElement;o&&!o.contains(t.contentDOM)&&o.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),o=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:o.from,u=s?s.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(o){o.docChanged&&(n.pos=o.changes.mapPos(n.pos),s=s.map(o.changes))},get(o,c,u){let f=t.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let o=s.posAtStart,c=o+s.length;(o>=n.to||c<=n.from)&&(n=ke.undirectionalRange(o,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",xc(t.state,nh,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=xc(t.state,th,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,c=r&&o&>(t,e)?{from:o.from,to:o.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,o=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),o()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let c=t.doc.lineAt(o);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:xc(t,nh,e.join(t.lineBreak)),ranges:n,linewise:r}}let ph=null;Mi.copy=Mi.cut=(t,e)=>{if(!jo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;ph=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=Gb?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let o=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(o&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return hh(t,{from:f,to:h,insert:t.state.toText(o)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(o=>o.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>o+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ox(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=o,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>vc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let o=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=o.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:o.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fo*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(o>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,o-=u.size}else break;else if(s=o&&c(this.lineAt(0,Rt.ByPos,r,s,o))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ax{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,o=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);c=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else c=this.height/o;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:o,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let o=r[r.length-1];o instanceof hn?r[r.length-1]=new hn(o.length+s):r.push(null,new hn(s-1))}if(e>0){let o=r[0];o instanceof hn?r[0]=new hn(e+o.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let o=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=o&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=vc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=o&&c.push(null,new hn(o-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=vc||Math.abs(f-this.heightMetrics(e,n).perLine)>=vc)&&(ml=!0),wc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class oj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let o=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,o).join(h)}forEachLine(e,n,r,s,o,c){let u=s+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,o);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let o=[];e>0&&this.decomposeLeft(e,o);let c=o.length;for(let u of r)o.push(u);if(e>0&&cx(o,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=wc(this.left,e),this.right=wc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:o,right:c}=this,u=n+o.length+this.break,f=null;return s&&s.from<=n+o.length&&s.more?f=o=o.updateHeight(e,n,r,s):o.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(o,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const aj=5;class mh{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=aj)&&this.addLineDeco(s,o,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();o=Math.max(o,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:o-n.left,right:Math.max(o,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class gh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=on.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:o,to:c})=>s>=o&&s<=c)){let{from:o,to:c}=this.lineBlockAt(s);e.push(new Sc(o,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new yh(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(_o(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,o=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ox(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,o=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(o,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ox();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,o=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new Sc(s.lineAt(c-r*1e3,Rt.ByHeight,o,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,o,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,o,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&o>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new gh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(o,c){r.push({from:o,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||_o(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||_o(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return _o(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}}class Sc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,o=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),o+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:o,to:c}=e[s],u=c-o;if(r<=u)return o+r;r-=u}}function kc(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(uc).filter(r=>typeof r!="function"),n=t.facet(sh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class yh{constructor(e,n,r){let s=0,o=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-o)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),o=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let o=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function _o(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>_o(s,e)):t._content)}const Cc=Ue.define({combine:t=>t.join(" ")}),bh=Ue.define({combine:t=>t.indexOf(!0)>-1}),xh=ol.newName(),hx=ol.newName(),px=ol.newName(),mx={"&light":"."+hx,"&dark":"."+px};function vh(t,e,n){return new ol(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=vh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),wh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!jo(this.dom,s))return;let o=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&Eo(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=To(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=jo(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&cl(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let o of e){let c=this.readMutation(o);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&jo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!gc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return Eo(c.node,c.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:o,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&othis.to&&(f=o);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));gc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);hh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],o=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let o of r.getTextFormats()){let c=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),h=this.toEditorPos(o.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=To(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((o,c,u,f,h)=>{if(r)return;let g=h.length-(c-o);if(s&&c>=s.to)if(s.from==o&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(o+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(othis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(o=>r(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(cc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new ih(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,o=this.state;for(let v of e){if(v.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=v.state}if(this.destroyed){this.viewState.state=o;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(o,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(g=null)):this.observer.clear(),o.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(o);s=dc.create(this,o,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(cc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Nc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Cc)!=s.state.facet(Cc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(eh))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new ih(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let o of r){let c=n.indexOf(o);if(c<0)s.push(new ih(o));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))o=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);o=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=dc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?o<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(eh))f(n)}get themeClasses(){return xh+" "+(this.state.facet(bh)?px:hx)+" "+this.state.facet(Cc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,rh,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),o=tb(this.dom,this.editorAttrs,e);return s||o});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let e=this.state.facet(Xe.cspNonce);ol.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return dh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return dh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),o=r[n?r.length-1:0];return ke.cursor(o.side(n,s)+e.from,o.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return dh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=fh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),fh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,o.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==n&&(o.fresh||mb(o.isolates,r=Mb(this,e))))return o.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Nc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(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,n={}){var r,s,o,c;return cc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(o=n.yMargin)!==null&&o!==void 0?o:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return cc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=ol.newName(),s=[Cc.of(r),Ro.of(vh(`.${r}`,e))];return n&&n.dark&&s.push(bh.of(!0)),s}static baseTheme(e){return Qa.lowest(Ro.of(vh("."+xh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ro,Xe.inputHandler=Sb,Xe.clipboardInputFilter=th,Xe.clipboardOutputFilter=nh,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=eh,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=uc,Xe.blockWrappers=Eb,Xe.outerDecorations=sh,Xe.atomicRanges=Mo,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=bh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=rh,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Nc{constructor(e,n,r,s,o,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=o,this.order=c}static update(e,n){if(n.empty&&!e.some(o=>o.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let o=Math.max(0,e.length-10);o=0;s--){let o=r[s],c=typeof o=="function"?o(t):o;c&&Kf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,o,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},o=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,Sh))}let f=c[e]||c.key;if(f)for(let h of u)o(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&o(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let Sh=null;function Ej(t,e,n,r){Sh=e;let s=UN(e),o=kN(s,0),c=CN(o)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Tc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Tc(A,e,!0)])||e.shiftKey&&(C=Ao[e.keyCode])!=s&&C!=A&&v(w[u+Tc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Tc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),Sh=null,f}class Ds{constructor(e,n,r,s,o){this.className=e,this.left=n,this.top=r,this.width=s,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let o=Sx(e);return[new Ds(n,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let o=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:o.left+1,y:c}),f=t.posAtCoords({x:o.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),o=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=uh(t,r,1),A=uh(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;we>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(we,q),L==null&&we>=be,ae.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(jc)!=e.state.facet(jc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(jc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const jc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),jc.of(t)]}const gl=Ue.define({combine(t){return Rf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(o&&Oe.ios&&n.iosSelectionHandles)){let c=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let o of Ds.forRange(t,"cm-selectionBackground",s))e.push(o);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Qa.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=on.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return on.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const Ec=Ue.define(),Hj=Ue.define(),Oc=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Oc).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Ec),this.view.viewport.from),r=[],s=this.gutters.map(o=>new Vj(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let c=!0;for(let u of o.type)if(u.type==fn.Text&&c){Ah(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(o.type==fn.Text){Ah(n,r,o.from);for(let c of s)c.line(this.view,o,r)}else if(o.widget)for(let c of s)c.widget(this.view,o);for(let o of s)o.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Oc),n=t.state.facet(Oc),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Ec),t.state.facet(Ec),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let o of n){let c=e.indexOf(o);c<0?s.push(new Ox(this.view,o)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let o of this.gutters)o.dom.remove(),s.indexOf(o)<0&&o.destroy();for(let o of s)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Ah(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,o=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,o,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,o,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Ah(this.cursor,s,n.from),r.length&&(s=s.concat(r));let o=this.gutter.config.lineMarker(e,n,s);o&&s.unshift(o);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let o of e.state.facet(Hj)){let c=o(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let o=s.target,c;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let o=0,c=0;;){let u=c,f=oo(u,f,h)||c(u,f,h):c}return r}})}});class kh extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ch(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Oc.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new kh(Ch(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let o=s(e,n,r);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new kh(Ch(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=Ch(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new kh(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Nh{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class Lo{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(s)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return s}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 n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),o=-1;o<(s?s.length:0);o++){let c=n[o<0?r.name:s[o]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Mc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,o){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,o&&o.length){this.props=Object.create(null);for(let[c,u]of o)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=Lo.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Eh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Mc.get(this)||this.topNode,o=new Eh(s);return o.moveTo(e,n),Mc.set(this,o._tree),o}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=qo(Mc.get(this)||this.topNode,e,n,!1);return Mc.set(this,r),r}resolveInner(e,n=0){let r=qo(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:o=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=o&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Mh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Th{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Th(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,o=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function qo(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(o&Pt.EnterBracketed&&g instanceof pn&&(v=Lo.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(o&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(o&Pt.IncludeAnonymous||!g.type.isAnonymous||Oh(g)){let w;if(!(o&Pt.IgnoreMounts)&&(w=Lo.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return o&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,o)}}}if(o&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=Lo.get(this._tree))&&s.overlay){let o=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=o:u=o:f>o))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return o}for(;;){if(r!=null&&s.type.is(r))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return r==null?o:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,o=r.buffer[this.index+3];if(o>s){let c=r.buffer[this.index+1];e.push(r.slice(s,o,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let o=1;on.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+o.from,-1,o);(s||(s=[r])).push(qo(u,e,n,!1))}}return s?Ix(s):r}class Eh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let o=n+e,c=e<0?-1:r._tree.children.length;o!=c;o+=e){let u=r._tree.children[o];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Oh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=o+1;break e}s=this.stack[--o]}for(let s=r;s=0;o--){if(o<0)return jh(this._tree,e,s);let c=r[n.buffer[this.stack[o]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Oh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Oh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:o=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Th(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=o[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],ae,he,we=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);ae=new Ur(T,be-he.start,r),we=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);ae=Mh(J,z,me,0,z.length,0,be-ee,qe,qe)}else ae=C(J,z,me,be-ee,ge-be,q)}M.push(ae),G.push(we)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(yt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[yt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[yt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Rc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Rc(t,r)}Hx.set(e,n)}return n}function Mh(t,e,n,r,s,o,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Mh(t,A,C,R,j,_,M,null,f))}v.push(_+O-o)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,o=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(o?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let o of n)o.to>e.length&&s.push(o);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],o=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=onew Nh(s.from,s.to)):[new Nh(0,0)]:[new Nh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let o=s.advance();if(o)return o}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let o of n.set)s.set.push(o);return s}static defineModifier(e){let n=new Dc(e);return r=>r.modified.indexOf(n)>-1?r:Dc.get(r.base||r,r.modified.concat(n).sort((s,o)=>s.id-o.id))}}let lE=0;class Dc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&oE(n,u.modified));if(r)return r;let s=[],o=new yi(e.name,s,e,n);for(let u of n)u.instances.push(o);let c=aE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Dc.get(u,f));return o}}function oE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function aE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let o=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(o.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=o.length-1,h=o[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new _c(r,c,f>0?o.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let o=new _c(s.tags,s.mode,s.context);n?n.next=o:r=o,n=o}return r}});class _c{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of o)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const Ee=yi.define,Lc=Ee(),Fr=Ee(),zx=Ee(Fr),Ux=Ee(Fr),Pr=Ee(),qc=Ee(Pr),Rh=Ee(Pr),Yi=Ee(),Ls=Ee(Yi),Ki=Ee(),Gi=Ee(),Dh=Ee(),Bo=Ee(Dh),Bc=Ee(),rt={comment:Lc,lineComment:Ee(Lc),blockComment:Ee(Lc),docComment:Ee(Lc),name:Fr,variableName:Ee(Fr),typeName:zx,tagName:Ee(zx),propertyName:Ux,attributeName:Ee(Ux),className:Ee(Fr),labelName:Ee(Fr),namespace:Ee(Fr),macroName:Ee(Fr),literal:Pr,string:qc,docString:Ee(qc),character:Ee(qc),attributeValue:Ee(qc),number:Rh,integer:Ee(Rh),float:Ee(Rh),bool:Ee(Pr),regexp:Ee(Pr),escape:Ee(Pr),color:Ee(Pr),url:Ee(Pr),keyword:Ki,self:Ee(Ki),null:Ee(Ki),atom:Ee(Ki),unit:Ee(Ki),modifier:Ee(Ki),operatorKeyword:Ee(Ki),controlKeyword:Ee(Ki),definitionKeyword:Ee(Ki),moduleKeyword:Ee(Ki),operator:Gi,derefOperator:Ee(Gi),arithmeticOperator:Ee(Gi),logicOperator:Ee(Gi),bitwiseOperator:Ee(Gi),compareOperator:Ee(Gi),updateOperator:Ee(Gi),definitionOperator:Ee(Gi),typeOperator:Ee(Gi),controlOperator:Ee(Gi),punctuation:Dh,separator:Ee(Dh),bracket:Bo,angleBracket:Ee(Bo),squareBracket:Ee(Bo),paren:Ee(Bo),brace:Ee(Bo),content:Yi,heading:Ls,heading1:Ee(Ls),heading2:Ee(Ls),heading3:Ee(Ls),heading4:Ee(Ls),heading5:Ee(Ls),heading6:Ee(Ls),contentSeparator:Ee(Yi),list:Ee(Yi),quote:Ee(Yi),emphasis:Ee(Yi),strong:Ee(Yi),link:Ee(Yi),monospace:Ee(Yi),strikethrough:Ee(Yi),inserted:Ee(),deleted:Ee(),changed:Ee(),invalid:Ee(),meta:Bc,documentMeta:Ee(Bc),annotation:Ee(Bc),processingInstruction:Ee(Bc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var _h;const $c=new yt,fE=new yt;class ar{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((o,c,u)=>{let f=Vx(o,c,u),h=f.type.prop($c);if(!h)return[];let g=o.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,o)){let A=o.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop($c)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(o,c)=>{if(o.prop($c)==this.data){r.push({from:c,to:c+o.length});return}let u=o.prop(yt.mounted);if(u){if(u.tree.prop($c)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+o.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let $o=null;class Ic{constructor(e,n,r=[],s,o,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=o,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Ic(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=$o;$o=this;try{return e()}finally{$o=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:o,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,o=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let o=s[0].from,c=s[s.length-1].to;return{parsedPos:o,advance(){let f=$o;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return $o}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Ic.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}ar.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(ar.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Lh=typeof navigator<"u"&&(!((_h=navigator.scheduling)===null||_h===void 0)&&_h.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=o.context.work(()=>Lh&&Lh()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ar.setState.of(new bl(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[ar.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),qh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Hc(t){let e=t.facet(qh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function zc(t,e){let n="",r=t.tabSize,s=t.facet(qh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let o=0;o=e?yE(t,n,e):null}class Uc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Hc(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:o}=this.options;return s!=null&&s>=r.from&&s<=r.to?o&&s==e?{text:"",from:e}:(n<0?s-1&&(o+=c-this.countColumn(r,r.search(/\S|$/))),o}countColumn(e,n=e.length){return nc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),o=this.options.overrideIndentation;if(o){let c=o(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let o=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)o.push(c);for(let c=o.length-1;c>=0;c--)r={node:o[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(Bh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,o=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,o&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class Bh extends Uc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Bh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(n.from),c=s==null||s<=o.from?o.to:Math.min(o.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let o=t.textAfter,c=o.match(/^\s*/)[0].length,u=r&&o.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function $h(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function Ih(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,o=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=$h(f.type,n,o);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,o)}}return jE(t,e,n,c,u.type,s,o)}function TE(t,e,n,r,s,o,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&o.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=o;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Hh(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Hh(h,`Modifier ${h} used at start of tag`):f.length?Hh(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Hh(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),o=Jx[s];if(o)return o.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Uh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function zh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=zh($E,0),_E=zh(Qx,0),LE=zh((t,e)=>Qx(t,e,BE(e)),0);function Uh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Io=50;function qE(t,{open:e,close:n},r,s){let o=t.sliceDoc(r-Io,r),c=t.sliceDoc(s,s+Io),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(c)[0].length,h=o.length-u;if(o.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*Io?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+Io),b=t.sliceDoc(s-Io,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(o=>Uh(e,o.from).block);if(!r.every(o=>o))return null;let s=n.map((o,c)=>qE(e,r[c],o.from,o.to));if(t!=2&&!s.every(o=>o))return{changes:e.changes(n.map((o,c)=>s[c]?[]:[{from:o.from,insert:r[c].open+" "},{from:o.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(o=>o)){let o=[];for(let c=0,u;cs&&(o==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;vo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&o.push({from:u.from+h,insert:f+" "});let c=e.changes(o);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,o.push({from:h,to:g})}return{changes:o}}return null}const Vh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Rf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Vh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Fc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return o?t=t.addChanges(o,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Fh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Vc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let o=s.pop(t,n,e);return o?(r(o),!0):!1}}const ev=Vc(0,!1),Fh=Vc(1,!1),UE=Vc(0,!0),VE=Vc(1,!0);class zn{constructor(e,n,r,s,o){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=o}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let o=s(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Fc(t,e,n,r){let s=e+1>n+20?e-n-1:0,o=t.slice(s,e);return o.push(r),o}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,o)=>n.push(s,o)),e.iterChangedRanges((s,o,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Fc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Ph(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let o=t.slice(0,n);return o[n-1]=s,o}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(o):o;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(o),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,o){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Pc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function ov(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Pc(n,e))}const JE=t=>ov(t,!Nn(t)),QE=t=>ov(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let o=r.type.prop(s),c,u;return o&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Yc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Yc(t.state,e,Nn(t)));function av(t,e){return _i(t,n=>{if(!n.empty)return Pc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>av(t,!1),uv=t=>av(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Pc(c,e));if(s.eq(r.selection))return!1;let o;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Yh=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(s=ke.cursor(r.from+o))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function oO(t,e,n){let r=!1,s=wl(t.selection,o=>{let c=vl(t,o.head,-1)||vl(t,o.head,1)||o.head>0&&vl(t,o.head-1,1)||o.headoO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let o=n(s);return ke.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Yc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Yc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Gc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),o=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let o of n.selection.ranges){let c=n.doc.lineAt(o.head);if(e?c.to0)for(let u=o;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ho(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(o=>{let{from:c,to:u}=o;if(c==u){let f=e(o);fc&&(n="delete.forward",f=Kc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Kc(t,c,!1),u=Kc(t,u,!0);return c==u?{range:o}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,o)=>{se&&(e=n?o:s)});return e}const Ev=(t,e,n)=>Ho(t,r=>{let s=r.from,{state:o}=t,c=o.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ho(t,n=>{let r=n.head,{state:s}=t,o=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?o.to:o.from)){r==n.head&&o.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(o.text,r-o.from,e)+o.from,h=o.text.slice(Math.min(r,f)-o.from,Math.max(r,f)-o.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ho(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headHo(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ho(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,o=t.doc.lineAt(s),c=s==o.from?s-1:kn(o.text,s-o.from,!1)+o.from,u=s==o.to?s+1:kn(o.text,s-o.from,!0)+o.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=o.to,c.ranges.push(r)}else e.push({from:s.from,to:o.to,ranges:[r]});n=o.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let o of Gc(t)){if(n?o.to==t.doc.length:o.from==0)continue;let c=t.doc.lineAt(n?o.to+1:o.from-1),u=c.length+1;if(n){r.push({from:o.to,to:c.to},{from:o.from,insert:c.text+t.lineBreak});for(let f of o.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:o.from},{from:o.to,insert:t.lineBreak+c.text});for(let f of o.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let o of Gc(t))n?r.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):r.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Gc(e).map(({from:s,to:o})=>(s>0?s--:o{let o;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(o=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,o)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),o;return r&&s&&r.to<=e&&s.from>=e&&(o=r.type.prop(yt.closedBy))&&o.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:o,to:c}=s,u=e.doc.lineAt(o),f=!t&&o==c&&qO(e,o);t&&(o=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new Uc(e,{simulateBreak:o,simulateDoubleBreak:!!f}),g=Yx(h,o);for(g==null&&(g=nc(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));cu.from&&o{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let o=t.changes(s);return{changes:s,range:ke.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Uc(t,{overrideIndentation:o=>{let c=n[o];return c??-1}}),s=Gh(t,(o,c,u)=>{let f=Yx(r,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let h=/^\s*/.exec(o.text)[0],g=zc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(qh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let o=nc(s,t.tabSize),c=0,u=zc(t,Math.max(0,o-Hc(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Kh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Yh}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Yh,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Yh,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Kh,shift:Kh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:aO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:o}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),o!==void 0&&(c["aria-expanded"]=String(o)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const zo=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:o=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,ae=J)=>{const he=O.current;if(!he)return;const we=he.state.doc.length,T=Math.max(0,Math.min(J,we)),z=Math.max(0,Math.min(ae,we));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const ae=O.current;if(!ae)return null;const he=Math.max(0,Math.min(J,ae.state.doc.length)),we=ae.coordsAtPos(he);return we?{left:we.left,right:we.right,top:we.top,bottom:we.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,ae=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Qa.highest(Xe.domEventHandlers({keydown:we=>(_.current?.(we),we.defaultPrevented)})),Xe.updateListener.of(we=>{we.docChanged&&!L.current&&j.current(we.state.doc.toString()),(we.selectionSet||we.docChanged)&&R.current?.(we.state.selection.main.head)})]}),he=new Xe({state:ae,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const ae=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(ae.anchor,e.length),head:Math.min(ae.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(o,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});zo.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Xh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(o,c)=>n(e.map((u,f)=>f===o?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((o,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:o.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:o.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:o.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||po(t),s=n==="dark",o=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Xh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(zo,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:o,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Xh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${o}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${o}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Xh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${o}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(zo,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(zo,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const o=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,o]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>o(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>o("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} -});`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;a{const u=a.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` +`).map(o=>{const u=o.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` `)}function Pv(t,e){return t.slice(0,Math.max(0,Math.min(e,t.length))).replace(/\r\n?/g,` `).length}function Yv(t,e,n){const r=t.split(` `),s=e.split(` -`),a=t.slice(0,Math.max(0,Math.min(n,t.length))),c=a.split(` -`).length-1,u=a.lastIndexOf(` -`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),o=t.slice(0,Math.max(0,Math.min(n,t.length))),c=o.split(` +`).length-1,u=o.lastIndexOf(` +`),f=o.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),o=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(o,s.length),selectionEnd:Math.min(Math.max(o,c),s.length)}}const Jh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Jh,"flex.collection":Jh,"flex.variables":Jh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,o)=>s.localeCompare(o)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,o]of r){const c=n.match(s);if(c)return{path:o,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function o3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function a3(t,e,n,r={},s=!1){const o=Math.max(0,Math.min(e,t.length)),c=t.slice(0,o),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:o-u.prefix.length,to:o,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:o-f.prefix.length,to:o,items:v}:null}const h=o3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:o-h.prefix.length,to:o,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:o-g.length,to:o,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:o={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,ae=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,ae))})},j=(B,K,ee=!1)=>{const be=a3(B,K,r,o,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(ao,{className:"h-3.5 w-3.5"}):p.jsx(Od,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(zo,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Xc="API-host execute route",Jc="the execute path";function Qc(t,e){return`${Xc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Qc("was unauthorized",`documentation authentication for ${Jc}`):t===403?Qc("was rejected",`CSRF, same-origin, and authorization middleware for ${Jc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Xc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Xc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Jc}.`:Qc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const o=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await o.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return o.status===429||o.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):o.redirected?Qc("was redirected",`authentication middleware for ${Jc}`):o.ok?`${Xc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(o.status,o.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Qh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Qh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Qh(n);if(!r)return t;const s=Qh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const o=new URL(t),c=`${o.pathname==="/"?"":o.pathname}${o.search}${o.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||po(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:o}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${o}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${o}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),o=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:o}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:o="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",ae=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",we=J||ae||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(ae),[qe,He]=I.useState(he),Je=I.useRef(we),$e=I.useRef(we),[ft,At]=I.useState(null),[bt,Ge]=I.useState(),[Q,re]=I.useState(null),[Se,Ne]=I.useState(null),[Be,We]=I.useState([]),[lt,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),ve=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Te=["GET","HEAD"].includes(Ae),je=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${je}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&o!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Fo=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=po(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Fo},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>o==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${le}-script-tab-${se}`,En=se=>`${le}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&o!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),ve.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Po=E?E(T.auth):T.auth,Qr=Pa({request:{...T,auth:Po},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),lu=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(ft,{...T,auth:Po},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ht(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Be.filter(se=>se.passed).length,Yo=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Yo&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${je}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||$e.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${je}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{ve.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Te&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:je,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:je,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(xf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:o==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>lu(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),o==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${je}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),o==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${je}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(bf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Yo,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(co,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),Se&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Se]}),ft&&p.jsx(QO,{response:ft,theme:s,curlCommand:bt,advanced:o==="advanced"}),Be.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Be.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Be.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),lt.length>0&&p.jsx(Rr,{code:lt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Wh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:o,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(o,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(o||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>hf(K),[K]),ae=t1(D,_)!==t1(w.request,A),he=C==="advanced",we=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Wh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(bf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${we}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&ae&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(La,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${we}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Wh("tab",ne)},onScriptTabChange:ne=>{B(ne),Wh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>pf(Ce,ne))})]})};function Wc(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(t){if(!t)return"";try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"?e.origin:""}catch{return""}}function T3(t,e,n,r){const s=e.startsWith("/")?e:`/${e}`;return{method:t.toUpperCase(),url:n?`${n}${s}`:s,auth:{type:"none"},...r?{hostExecution:{preferHostExecution:!0}}:{}}}function j3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function E3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const O3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:o,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=j3(),h=o??nf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L){if(!(c?.runtimeOnly?.some(lt=>lt.path===e&<.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(lt=>lt.code==="runtime.operation-undocumented"&<.location.path===e&<.location.method?.toUpperCase()===n.toUpperCase())))return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const Se=N3(c?.serverOrigin),Ne=s.tryIt?.hostExecution,Be=Ne?.available===!0&&Ne.preferHostExecution!==!1,We=()=>u?.({request:T3(n,e,Se,Be),serverUrl:Se||void 0,scripts:{preRequest:"",tests:""},requestTab:"params",scriptTab:"pre-request"});return p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsxs("dl",{className:`mt-4 space-y-3 text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:[p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.contractEvidence||"Contract"}),p.jsx("dd",{children:ce?.contractNotDeclared||"OpenAPI does not declare this operation."})]}),p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.runtimeEvidence||"Runtime"}),p.jsx("dd",{children:ce?.runtimeRouteUndocumented||`${n.toUpperCase()} ${e} is registered by the running service.`})]})]}),u&&p.jsxs("button",{type:"button",className:"mt-4 inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:We,children:[p.jsx(La,{className:"h-4 w-4"}),ce?.openApiClient||"Open in API Client"]})]})}if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",ae=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,we={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const Se=!A.has(re);w(Ne=>{const Be=new Set(Ne.key===b?Ne.sections:g);return Be.has(re)?Be.delete(re):Be.add(re),{key:b,sections:Be}}),re==="tryIt"&&E3("tryIt",Se?"1":void 0)},He=(re,Se,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Se}-heading`,children:[p.jsxs("button",{type:"button",id:`${Se}-heading`,"aria-expanded":A.has(Se),onClick:()=>qe(Se),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Se)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(Se)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},$e=(re,Se)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=ae.indexOf(Se),Be=re.key==="Home"?ae[0]:re.key==="End"?ae[ae.length-1]:re.key==="ArrowRight"?ae[(Ne+1)%ae.length]:ae[(Ne-1+ae.length)%ae.length];Je(Be)},ft=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wc(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,bt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{ft()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Cd,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&bt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:bt.map(([re,Se])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof Se=="string"?Se:JSON.stringify(Se)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...we})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,Se])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),Se.schema&&p.jsx(Dr,{spec:t,schema:Se.schema,theme:r,...we}),Se.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Se.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,Se])=>{const Ne=In.isReference(Se)?In.resolveReference(t,Se.$ref):Se;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([Be,We])=>{const lt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:Be}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...we})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),lt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(lt.value??lt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Be)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:ae.map(re=>p.jsx("button",{ref:Se=>{R.current[re]=Se},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:Se=>$e(Se,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function M3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function R3(t,e){let n=M3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function D3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const o of In.getHttpMethods(s)){const c=s[o];n.push({path:r,method:o,operation:c,score:R3(c,o),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const _3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",o=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=D3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:o,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${o}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${o}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${o}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${o}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${o}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${o}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(La,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(La,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${o}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${o}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const L3=typeof n1>"u"?{commit:"unknown"}:n1,q3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=L3,o=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),o]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},B3=(t,e,n)=>t==="dark"?n:e,$3="Runtime intelligence returned an invalid snapshot.",I3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),H3=new Set(["error","warning","info"]),z3=new Set(["pass","warn","fail","partial"]);function sn(){throw new Error($3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&sn(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&sn(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];sn()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&sn(),n}function U3(t){return Ji(t)||sn(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||sn(),t.map(U3)}function V3(t){(!Ji(t)||!Ji(t.location))&&sn();const e=Un(t,"code"),n=Un(t,"severity");(!I3.has(e)||!H3.has(n)||t.location.kind!=="operation")&&sn();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const o=i1(t,"expected");o!==void 0&&(r.expected=o);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),t.disposition!==void 0&&(t.disposition!=="acknowledged"&&sn(),r.disposition="acknowledged"),r}function F3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&sn();const e=Un(t,"status");z3.has(e)||sn();const n=t.findings.map(V3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&sn();const o=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==o&&sn(),{status:e,complete:t.complete,findings:n,summary:r}}function P3(t){Ji(t)||sn(),(!Ji(t.runtime)||!Ji(t.summary))&&sn(),typeof t.discoveryComplete!="boolean"&&sn();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const o=Zh(t,"serverOrigin");if(o&&(r.serverOrigin=o),t.server!==void 0){Ji(t.server)||sn();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&sn(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||sn(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=F3(t.validation)),r}const Y3=60;function K3(t,e,n=Y3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function G3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const X3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:o,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:o},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,o,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=K3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=G3(C.current);if(!J.length)return;const ae=J[0],he=J[J.length-1],we=document.activeElement;q.shiftKey&&(we===ae||!C.current.contains(we))?(q.preventDefault(),he.focus()):!q.shiftKey&&(we===he||!C.current.contains(we))&&(q.preventDefault(),ae.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},J3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function Q3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:o,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=W3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(o)?o.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:Q3(o),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(o)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),J3[D]]},D))]}),o!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function eM(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const tM=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:o,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),o();return}if(j.key!=="Tab"||!f.current)return;const R=eM(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,o]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:o}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:o,children:p.jsx(Md,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(nM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),o())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function nM({result:t,theme:e,messages:n,onSelect:r}){const o=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:o,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code}),u.disposition==="acknowledged"&&p.jsx("span",{children:n?.acknowledgedFinding||"acknowledged"})]}),p.jsx("div",{className:`mt-1 text-xs ${o}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${o}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${o}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:o,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>o?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>o(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function iM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Zc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function eu(t){return Array.isArray(t)?`[${t.map(eu).join(",")}]`:Zc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${eu(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function rM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function o1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){o1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function sM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function a1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let o=n?s.get(n):void 0;for(;o&&!r.has(o.id);)r.add(o.id),o=o.parentFolderId?s.get(o.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const o of t.folders)o.collectionId!==e||!o.parentFolderId||r.has(o.id)||r.has(o.parentFolderId)&&(r.add(o.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const o=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))o.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&o.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function lM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[sM(r)],activeEnvironmentId:r.id}}function oM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=a1(r,e),o=f1(r,e);h1(o,e);const c=lM(r,n.environmentId),u={version:6,collections:[rM(s)],folders:d1(r,e),requests:o,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function aM(t){if(!Zc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function tu(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function cM(t,e){const n=a1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(o=>o.id===e.folderId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(o=>o.id===e.requestId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function uM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function dM(t){if(!Zc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Zc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=aM(t.scope),n=uM(t.workspace),r=oy(n);if(eu(n)!==eu(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");tu(r.collections,"collection"),tu(r.folders,"folder"),tu(r.requests,"request"),tu(r.environments,"environment"),cM(r,e);for(const s of r.requests)o1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function fM(t){return`${JSON.stringify(dM(t),null,2)} +`}function hM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let o=!0;for(;o;){o=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),o=!0)}return s}function Sl(t,e,n){const r=hM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function pM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(o=>o.id===e)?.name||"Deleted collection";if(!n)return r;const s=pM(t.folders.filter(o=>o.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function mM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function gM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const o=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=pf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&mM(E);let j;E.result&&!D&&(s=ay(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(o.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=o.filter(g=>g.cancelled).length,h=o.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:o.length,passed:u,failed:h,cancelled:f,stopped:c,items:o,workspace:s}}function Gr(){return new Date().toISOString()}function yM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const bM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:o,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,Se=(Ne,Be)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:Be}),Se(We.id,Be+1))})};return Se(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),Se(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],Se=new Set;let Ne=K.get(Q);for(;Ne&&!Se.has(Ne.id);)Se.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const Se=oM(h,Q),Ne=new Blob([fM(Se)],{type:"application/json;charset=utf-8"}),Be=URL.createObjectURL(Ne),We=document.createElement("a");We.href=Be,We.download=yM(re),We.click(),setTimeout(()=>URL.revokeObjectURL(Be),0),L("")}catch(Se){L(Se instanceof Error?Se.message:String(Se))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),Se=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:Se,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(Se),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(Se=>({...Se,folders:Se.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},ae=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(Se=>Se.id===M.id?{...Se,variables:[...Se.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:Se)}))},he=(Q,re)=>{if(!M)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Be=>Be.id===M.id?{...Be,variables:Be.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:Se}:Be)}))},we=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter(Be=>Be.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),Se=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:Se,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(Se),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map(Be=>Be.id===j?{...Be,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:Be)}));return}const Se={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,Se]})),R(Se.id),O(Q)},me=Q=>{const re=h.requests.find(Se=>Se.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(Se=>Se.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(Se=>Se.id===Q);g(Se=>LC(Se,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",$e=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),ft=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=be(Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return p.jsxs(kd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Be}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${Be} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},Be),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(lt=>ft(lt,re+1,Ne))]},Q.id)},At=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=Y.filter(lt=>lt.folderId===Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return Be.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Be.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:Be.map($e)})]}),We.map(lt=>At(lt,re+1,Ne))]},Q.id)},bt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>o?.(Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(xf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:ae,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:Se=>he(Q.id,{enabled:Se.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:Se=>he(Q.id,{key:Se.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:Se=>he(Q.id,{value:Se.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>we(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),bt.map(Q=>ft(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(xf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map($e),bt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function Uo(){return new Date().toISOString()}const xM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),o=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=Uo(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!o)return;const w=Uo();e(A=>({...A,environments:A.environments.map(C=>C.id===o.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!o)return;const C=Uo();e(E=>({...E,environments:E.environments.map(D=>D.id===o.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),o&&p.jsx("button",{type:"button","aria-label":`Delete environment ${o.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,o.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),o&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:o.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[o.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),o.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function nu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function vM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",o=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,o,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=nu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function wM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),o=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:o,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const o=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=kd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` -`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${o}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:o,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${o}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":o,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":o}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${o}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${o}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function op(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function AM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=AM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,o)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${o}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const kM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:o,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:o||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>vM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>wM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},ae=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],we=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:ae,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=nu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[op(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:nu(ne)?"text-red-600":j,children:op(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:nu(B)?"text-red-600":j,children:op(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[we,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ot(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?ot(r.value):""}function CM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function ap(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=CM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const o=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return o("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){o("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return o("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){o("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(o("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const o=ot(r.key).trim();return o?[{id:An("variable"),key:o,value:ot(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function NM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(o=>t.includes(o));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function TM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(ot).join(` +`):ot(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,o)=>{const c=ot(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${o}]`,f=TM(s.script,`${u}.script`,n).trim();if(!f)return;const h=NM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function jM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function EM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(o=>{const c=o.indexOf("=");return{key:S1(c>=0?o.slice(0,c):o),value:S1(c>=0?o.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function OM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function MM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=ot(r.key).trim();s&&(n=n.replace(new RegExp(`:${MM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function RM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=OM(t.query),n=ot(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=ot(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(ot).join("."):ot(t.host),o=ot(t.port),c=Array.isArray(t.path)?t.path.map(ot).join("/"):ot(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${o?`:${o}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function DM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function _M(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function LM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function qM(t,e,n,r){const s=_M(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const o=ot(t.mode);if(o==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?ot(c.language):"";return{body:ot(t.raw),contentType:s||LM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(o==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:ot(u.key),value:ot(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(o==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=ot(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:ot(c.query),variables:u},contentType:s||"application/json"}}if(o==="formdata"){const c=Xr(t.formdata).map(f=>{const h=ot(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(ot).filter(Boolean).join(", "):ot(f.src);return{key:ot(f.key),value:h==="text"?ot(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(o==="file"){const c=mn(t.file)?ot(t.file.src):ot(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${o}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function BM(t,e,n,r,s,o,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=ot(f.method).trim().toUpperCase()||"GET",g=RM(f.url),b=DM(f.header),v=qM(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:ap(f.auth,{type:"inherit"},`${c}.auth`,u)},A=EM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:o,updatedAt:o}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=ot(e.name)||"Untitled",o=w1(e.event,`${r}.event`,t.warnings),c=jM(t.inheritedScripts,o);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:ap(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=BM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function $M(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=ot(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=ot(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),o=An("collection"),c={id:o,name:e,auth:ap(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:o,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function IM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=ot(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function HM(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:$M(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:IM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function zM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function UM(t,e){const n=zM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function VM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const FM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,o]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=HM(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?UM(M,G.result):VM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?o({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?o({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):o({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(ao,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function PM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e.folderId);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function YM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const KM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const ae=await gM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(we=>({...we,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(we=>({...we,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(ae.workspace),Y(he=>Object.fromEntries(C.map(we=>{const T=he[we.id]||{status:"pending"};return[we.id,T.status==="pending"&&ae.stopped?{status:"skipped"}:T]}))),M(ae),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(co,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(co,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,ae)=>{const he=G[J.id]||{status:"pending"},we=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=we?.status!==void 0&&we.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:ae+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:PM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(ao,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:YM(he)}),we?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",we.status]}),we?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(Nd,{className:"mr-1 inline h-3.5 w-3.5"}),we.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Vo(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function GM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return po(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function XM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:o="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=GM(t),Y=Sn(e),B=nl(),K=o===!1?{}:j1(o),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[ae,he]=I.useState(Y),[we,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[$e,ft]=I.useState({}),[At,bt]=I.useState(),[Ge,Q]=I.useState(B),[re,Se]=I.useState(B.collections[0]?.id),[Ne,Be]=I.useState(""),We=I.useRef(B.collections[0]?.id),lt=I.useRef(void 0),[ti,Tn]=I.useState(o===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(o===!1)return;let Me=!1;return hy(o).then(Ze=>{Me||(Q(Ze),Se(Ze.collections[0]?.id),Be(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[o]);const x=my(o,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>hf(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,ae),[ce,ae]),V=I.useMemo(()=>XM(ce,ae)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,ae,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),ve=I.useCallback(Me=>{Se(Me),Be("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},le=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),o!==!1&&Vo(o,{requestTab:Me}),C?.(Me)},Te=Me=>{qe(Me),o!==!1&&Vo(o,{scriptTab:Me}),E?.(Me)},je=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>pf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,lt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>ay(Ze,{...Me,collectionId:We.current,folderId:lt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Se(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Be(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),o!==!1&&Vo(o,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{Se(Me),Be(Ze||""),bt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{ft({entryId:Me,runId:Ze}),Je("history")},Fo=()=>ni(Me=>{const Ze=!Me;return o!==!1&&Vo(o,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Fo,children:ht?p.jsx(Ed,{className:"h-4 w-4"}):p.jsx(jd,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(bf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(FM,{onWorkspaceChange:Q,onSelectedCollectionChange:ve,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(xM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(bM,{request:ce,scripts:ae,onLoadRequest:Dt,onSelectedCollectionChange:ve,onSelectedFolderChange:Be,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),o!==!1&&Vo(o,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(kM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:$e.entryId,initialRunId:$e.runId,theme:kt},`${$e.runId||""}:${$e.entryId||""}`):He==="runner"&&At?p.jsx(KM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:we,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:je,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:le,onRequestTabChange:Ae,onScriptTabChange:Te,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function iu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function JM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,o]of Object.entries(t.paths))for(const c of In.getHttpMethods(o)){if(Wc(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function QM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${iu(n.padding.vertical)||"0"} ${iu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:iu(n.maxHeight)||"32px",maxWidth:iu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const WM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const o=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=ho(o),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:o,preferences:c})),ae=I.useRef(null),he=I.useRef(null),we=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===o?q.preferences:ho(o),Je=n&&He.theme||e,$e=Je==="high-contrast"?"dark":Je,ft=He.expand,At=He.expandedTags??["default"],bt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...JM($e,Ge),...r}),[$e,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return P3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const le=R1(t,window.location.hash);if(le){g(le);return}const Ae=window.location.hash.replace(/^#/,"");g(Te=>Te&&Ae&&Wc(Te.path,Te.method)===Ae?Te:null)},de=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const le=ae.current,Ae=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Te=je=>{if(je.key==="Escape"){je.preventDefault(),M(!1);return}if(je.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];je.shiftKey&&document.activeElement===ze?(je.preventDefault(),Ve.focus()):!je.shiftKey&&document.activeElement===Ve&&(je.preventDefault(),ze.focus())};return document.addEventListener("keydown",Te),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Te),de?.focus()}},[L]);const re=()=>{J({key:o,preferences:ho(o)})},Se=F=>{J(de=>{const le=de.key===o?de.preferences:ho(o);return{key:o,preferences:{...le,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>we.current?.scrollTo({top:0,behavior:"auto"})),Be=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wc(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},lt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!bt;Ba(o,"sidebarCollapsed",F),Se({sidebarCollapsed:F})},ht=nf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ft===void 0?ht:nf(ft),Vn=F=>{Ba(o,"expand",F),re()},qn=F=>{n&&(Ba(o,"theme",F),re())},kt=F=>{Ba(o,"expandedTags",F),Se({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=B3($e,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=$e==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=$e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),ve=p.jsx(pk,{spec:t,onEndpointSelect:Be,theme:$e,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.logo?p.jsx(QM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(iM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${bt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":bt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!bt&&ve}),p.jsxs("main",{ref:we,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(O3,{spec:t,path:h.path,method:h.method,theme:$e,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:lt}):p.jsx(_3,{spec:t,onEndpointSelect:Be,theme:$e}),p.jsx(q3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:$e,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:ae,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${$e==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:ve})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${$e==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(tM,{open:B&&T,theme:$e,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:Be,messages:X}),p.jsx(X3,{spec:t,theme:$e,messages:X,onEndpointSelect:Be,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>lt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Z3,{open:G,theme:$e,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:ft,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function ZM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function eR(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function tR(t,e){const n=e.load||ZM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),o={},c=new Map;async function u(g){if(g===r)return s;if(o[g])return o[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return o[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=eR(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(o).length&&(s[dp]=o),s}async function nR(t,e){return tR(t,e)}const ru="1",su=new WeakMap;function iR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=iR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},o=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!o.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function rR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function sR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=su.get(t);n&&n.unmount();const r=$A.createRoot(t);return su.set(t,r),r.render(e),()=>{su.get(t)===r&&su.delete(t),r.unmount()}}function $1(t,e,n){return sR(n),B1(t,p.jsx(WM,{spec:fp(e,n),theme:rR(n),options:n}))}function I1(t,e){const n={contractVersion:ru,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:ru,...e.options||{}},r=e.baseUri?await nR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:ru}),As.FLEXDOC_CONTRACT_VERSION=ru,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/php/assets/flexdoc.standalone.js b/adapters/php/assets/flexdoc.standalone.js index 3efc5433..bf78a4d9 100644 --- a/adapters/php/assets/flexdoc.standalone.js +++ b/adapters/php/assets/flexdoc.standalone.js @@ -1,86 +1,86 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(q,J){var oe=q.length;q.push(J);e:for(;0>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1>>1,we=q[he];if(0>>1;hes(me,ae))nes(Ce,me)?(q[he]=Ce,q[ne]=ae,he=ne):(q[he]=me,q[z]=ae,he=z);else if(nes(Ce,ae))q[he]=Ce,q[ne]=ae,he=ne;else break e}}return J}function s(q,J){var ae=q.sortIndex-J.sortIndex;return ae!==0?ae:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var we=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof we=="function"){b.callback=we,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=ae,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=ae,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,ae-he))):(q.sortIndex=we,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var ae=v;v=J;try{return q.apply(this,arguments)}finally{v=ae}}}})(vd)),vd}var Ng;function RA(){return Ng||(Ng=1,xd.exports=MA()),xd.exports}var wd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function($e){return $e})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ad.exports=_A(),Ad.exports}var Mg;function qA(){if(Mg)return oo;Mg=1;var t=RA(),e=Sd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1we||(i.current=he[we],he[we]=null,we--)}function me(i,l){we++,he[we]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function $e(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,a=Q2(l,i.type);l!==a&&(me(Ce,i),me(ne,a))}function ft(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oa._currentValue=ae)}var At,bt;function Ge(i){if(At===void 0)try{throw Error()}catch(a){var l=a.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",bt=-1)":-1m||$[d]!==te[m]){var fe=` -`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ge(a):""}function Se(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",a=null;do l+=Se(i,a),a=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var $e=Object.prototype.hasOwnProperty,We=t.unstable_scheduleCallback,vt=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ft=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,kt=t.unstable_NormalPriority,x=t.unstable_LowPriority,U=t.unstable_IdlePriority,pe=t.log,ue=t.unstable_setDisableYieldValue,X=null,k=null;function V(i){if(typeof pe=="function"&&ue(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var W=Math.clz32?Math.clz32:de,we=Math.log,F=Math.LN2;function de(i){return i>>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(ve(i)/F|0)|0}var le=256,Ae=262144,Te=4194304;function je(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,a){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=je(d):(S&=N,S!==0?m=je(S):a||(a=N&~i,a!==0&&(m=je(a))))):(N=d&~y,N!==0?m=je(N):S!==0?m=je(S):a||(a=d&~i,a!==0&&(m=je(a)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,a=l&-l,y>=a||y===32&&(a&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Te;return Te<<=1,(Te&62914560)===0&&(Te=4194304),i}function Fn(i){for(var l=[],a=0;31>a;a++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Fo(i,l,a,d,m,y){var S=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(a=S&~a;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var oR=/[\n"\\]/g;function vi(i){return i.replace(oR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,a,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):a!=null?gp(i,S,On(a)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,a,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}a=a!=null?""+On(a):"",l=l!=null?""+On(l):a,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,a){l==="number"&&ou(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Tl(i,l,a,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Go={};Object.defineProperty(Go,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Go,Go),window.removeEventListener("test",Go,Go)}catch{wp=!1}var es=null,Sp=null,cu=null;function Q1(){if(cu)return cu;var i,l=Sp,a=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Qo),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return LR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function BR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function $R(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),cu=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:a,offset:l-i};i=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=pw(a)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=ou(i.document);l instanceof i.HTMLIFrameElement;){try{var a=typeof l.contentWindow.location.href=="string"}catch{a=!1}if(a)i=l.contentWindow;else break;l=ou(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var YR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,ta=null,Rp=!1;function bw(i,l,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Rp||Rl==null||Rl!==ou(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),ta&&ea(ta,d)||(ta=d,d=nd(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|a<it?(dt=Ie,Ie=null):dt=Ie.sibling;var vt=ie(P,Ie,Z[it],ye);if(vt===null){Ie===null&&(Ie=dt);break}i&&Ie&&vt.alternate===null&&l(P,Ie),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt,Ie=dt}if(it===Z.length)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;itit?(dt=Ie,Ie=null):dt=Ie.sibling;var Ss=ie(P,Ie,vt.value,ye);if(Ss===null){Ie===null&&(Ie=dt);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),xt===null?Fe=Ss:xt.sibling=Ss,xt=Ss,Ie=dt}if(vt.done)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;!vt.done;it++,vt=Z.next())vt=xe(P,vt.value,ye),vt!==null&&(H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return pt&&gr(P,it),Fe}for(Ie=d(Ie);!vt.done;it++,vt=Z.next())vt=oe(Ie,P,it,vt.value,ye),vt!==null&&(i&&vt.alternate!==null&&Ie.delete(vt.key===null?it:vt.key),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return i&&Ie.forEach(function(fD){return l(P,fD)}),pt&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){a(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){a(P,H.sibling),ye=m(H,Z.props),oa(ye,Z),ye.return=P,P=ye;break e}a(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=xu(Z.type,Z.key,Z.props,null,P.mode,ye),oa(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){a(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{a(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,Nu(Z),ye);if(Z.$$typeof===j)return Et(P,H,Su(P,Z),ye);Tu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(a(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(a(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):a(P,H)}return function(P,H,Z,ye){try{la=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===ku)throw Ie;var xt=li(29,Ie,null,P.mode);return xt.lanes=ye,xt.return=P,xt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function os(i,l,a){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=bu(i),Cw(i,null,a),l}return yu(i,d,l,a),bu(i)}function aa(i,l,a){if(l=l.updateQueue,l!==null&&(l=l.shared,(a&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}function Zp(i,l){var a=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var m=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var S={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,a=a.next}while(a!==null);y===null?m=y=l:y=y.next=l}else m=y=l;a={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=l:i.next=l,a.lastBaseUpdate=l}var em=!1;function ca(){if(em){var i=zl;if(i!==null)throw i}}function ua(i,l,a,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,oe=ie!==N.lane;if(oe?(ut&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=a;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=m.callbacks,oe===null?m.callbacks=[ie]:oe.push(ie))}else oe={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=oe,$=xe):fe=fe.next=oe,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;oe=N,N=oe.next,oe.next=null,m.lastBaseUpdate=oe,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,a);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=t4($,d);ha(i,l,fe,di(i))}else ha(i,l,d,di(i))}catch(xe){ha(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function o4(){}function ym(i,l,a,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,ae,a===null?o4:function(){return AS(i),a(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ae},next:null};var a={};return l.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ha(i,l.next.queue,{},di())}function bm(){return yn(Oa)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function a4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var a=di();i=ls(a);var d=os(l,i,a);d!==null&&(Qn(d,l,a),aa(d,l,a)),l={cache:Kp()},i.payload=l;return}l=l.return}}function c4(i,l,a){var d=di();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bu(i)?TS(l,a):(a=qp(i,l,a,d),a!==null&&(Qn(a,i,d),jS(a,l,d)))}function NS(i,l,a){var d=di();ha(i,l,a,d)}function ha(i,l,a,d){var m={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,a);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return yu(i,l,m,0),Mt===null&&gu(),!1}catch{}if(a=qp(i,l,m,d),a!==null)return Qn(a,i,d),jS(a,l,d),!0}return!1}function xm(i,l,a,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Bu(i)){if(l)throw Error(r(479))}else l=qp(i,a,d,2),l!==null&&Qn(l,i,2)}function Bu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=Ou=!0;var a=i.pending;a===null?l.next=l:(l.next=a.next,a.next=l),i.pending=l}function jS(i,l,a){if((a&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}var pa={readContext:yn,use:Du,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};pa.useEffectEvent=zt;var ES={readContext:yn,use:Du,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,a){a=a!=null?a.concat([i]):null,Lu(4194308,4,gS.bind(null,l,i),a)},useLayoutEffect:function(i,l){return Lu(4194308,4,i,l)},useInsertionEffect:function(i,l){Lu(4,2,i,l)},useMemo:function(i,l){var a=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return a.memoizedState=[d,l],d},useReducer:function(i,l,a){var d=$n();if(a!==void 0){var m=a(l);if(Js){V(!0);try{a(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=c4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,a=NS.bind(null,nt,l);return l.dispatch=a,[i.memoizedState,a]},useDebugValue:mm,useDeferredValue:function(i,l){var a=$n();return gm(a,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,a){var d=nt,m=$n();if(pt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=l(),Mt===null)throw Error(r(349));(ut&127)!==0||Jw(d,l,a)}m.memoizedState=a;var y={value:a,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,a,l),null),a},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(pt){var a=Zi,d=Wi;a=(d&~(1<<32-W(d)-1)).toString(32)+a,l="_"+l+"R_"+a,a=Mu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,a),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,a=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,a)),i||is(l,!0)}else i=id(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(a=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),a!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else a=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return l.flags&256?(ai(l),l):(ai(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(ai(l),l):(ai(l),null)}return ai(l),(l.flags&128)!==0?(l.lanes=a,l):(a=d!==null,i=i!==null&&i.memoizedState!==null,a&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),a!==i&&a&&(l.child.flags|=8192),Uu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)ga(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Eu(i),y!==null){for(l.flags|=128,ga(d,!1),i=y.updateQueue,l.updateQueue=i,Uu(l,i),l.subtreeFlags=0,i=a,a=l.child;a!==null;)Nw(a,i),a=a.sibling;return me(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Ku&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304)}else{if(!m)if(i=Eu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Uu(l,i),ga(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Ku&&a!==536870912&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,a=Kt.current,me(Kt,m?a&1|2:a&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return ai(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(a&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),a=l.updateQueue,a!==null&&Uu(l,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==a&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),l.memoizedState.cache!==a&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function p4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ft(l),null;case 31:if(l.memoizedState!==null){if(ai(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(ai(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return ai(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:ft(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&ai(l);break;case 13:ai(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:ai(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function ya(i,l){try{var a=l.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var m=d.next;a=m;do{if((a.tag&i)===i){d=void 0;var y=a.create,S=a.inst;d=y(),S.destroy=d}a=a.next}while(a!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,a){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=a,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var a=i.stateNode;try{Fw(l,a)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,a){a.props=Qs(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(d){Nt(i,l,d)}}function ba(i,l){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof a=="function"?i.refCleanup=a(d):a.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var a=i.ref,d=i.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(m){Nt(i,l,m)}else a.current=null}function n2(i){var l=i.type,a=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,a){try{var d=i.stateNode;q4(d,i.type,a,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,l):(l=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,l.appendChild(i),a=a._reactRootContainer,a!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,a),i=i.sibling;i!==null;)qm(i,l,a),i=i.sibling}function Vu(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?a.insertBefore(i,l):a.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vu(i,l,a),i=i.sibling;i!==null;)Vu(i,l,a),i=i.sibling}function r2(i){var l=i.stateNode,a=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,a),l[_t]=i,l[Yt]=a}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,an=null;function m4(i,l){if(i=i.containerInfo,rg=ud,i=yw(i),Op(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var oe;xe!==a||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(oe=xe.firstChild)!==null;)ie=xe,xe=oe;for(;;){if(xe===i)break t;if(ie===a&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(oe=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=oe}a=N===-1||$===-1?null:{start:N,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(sg={focusedElem:i,selectionRange:a},ud=!1,an=l;an!==null;)if(l=an,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,an=i;else for(;an!==null;){switch(l=an,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a title"))),xn(y,d,a),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(a.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(oe.rangeCount!==1||oe.anchorNode!==P.node||oe.anchorOffset!==P.offset||oe.focusNode!==H.node||oe.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),oe.removeAllRanges(),Ye>Et?(oe.addRange(Z),oe.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),oe.addRange(Z))}}}}for(xe=[],oe=N;oe=oe.parentNode;)oe.nodeType===1&&xe.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Na?32:a,q.T=null,a=Fm,Fm=null;var y=ps,S=jr;if(ln=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,a),wt=N,ka(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,a){l=Si(a,l),l=Am(i.stateNode,l,2),i=os(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,a){if(i.tag===3)q2(i,i,a);else for(;l!==null;){if(l.tag===3){q2(l,i,a);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(a,i),a=BS(2),d=os(l,a,2),d!==null&&($S(a,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,a){var d=i.pingCache;if(d===null){d=i.pingCache=new b4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(a)||(Hm=!0,m.add(a),i=A4.bind(null,i,l,a),l.then(i,i))}function A4(i,l,a){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ut&a)===a&&(Ut===4||Ut===3&&(ut&62914560)===ut&&300>ht()-Yu?(wt&2)===0&&Zl(i,0):zm|=a,Ql===ut&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function k4(i){var l=i.memoizedState,a=0;l!==null&&(a=l.retryLane),B2(i,a)}function C4(i,l){var a=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(a=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,a)}function N4(i,l){return We(i,l)}var Zu=null,to=null,Xm=!1,ed=!1,Jm=!1,gs=0;function tr(i){i!==to&&i.next===null&&(to===null?Zu=to=i:to=to.next=i),ed=!0,Xm||(Xm=!0,j4())}function ka(i,l){if(!Jm&&ed){Jm=!0;do for(var a=!1,d=Zu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,z2(d,y))}else y=ut,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(a=!0,z2(d,y));d=d.next}while(a);Jm=!1}}function T4(){$2()}function $2(){ed=Xm=!1;var i=0;gs!==0&&$4()&&(i=gs);for(var l=ht(),a=null,d=Zu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,a===null?Zu=m:a.next=m,m===null&&(to=a)):(a=d,(i!==0||(y&3)!==0)&&(ed=!0)),d=m}ln!==0&&ln!==5||ka(i),gs!==0&&(gs=0)}function I2(i,l){for(var a=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function oA(i,l,a){var d=no;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof a=="string"&&(m+='[crossorigin="'+a+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:a,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function K4(i){Er.D(i),oA("dns-prefetch",i,null)}function G4(i,l){Er.C(i,l),oA("preconnect",i,l)}function X4(i,l,a){Er.L(i,l,a);var d=no;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&a&&a.imageSrcSet?(m+='[imagesrcset="'+vi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(m+='[imagesizes="'+vi(a.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=io(i);break;case"script":y=ro(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&a&&a.imageSrcSet?void 0:i,as:l},a),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(ja(y))||l==="script"&&d.querySelector(Ea(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function J4(i,l){Er.m(i,l);var a=no;if(a&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ro(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),a.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ea(y)))return}d=a.createElement("link"),xn(d,"link",i),Xt(d),a.head.appendChild(d)}}}function Q4(i,l,a){Er.S(i,l,a);var d=no;if(d&&i){var m=fr(d).hoistableStyles,y=io(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(ja(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},a),(a=ji.get(y))&&fg(i,a);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,sd(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function W4(i,l){Er.X(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Z4(i,l){Er.M(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function aA(i,l,a,d){var m=(m=Re.current)?rd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(l=io(a.href),a=fr(m).hoistableStyles,d=a.get(l),d||(d={type:"style",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=io(a.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(ja(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ji.set(i,a),y||eD(m,i,a,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=a.async,a=a.src,typeof a=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ro(a),a=fr(m).hoistableScripts,d=a.get(l),d||(d={type:"script",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function io(i){return'href="'+vi(i)+'"'}function ja(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function eD(i,l,a,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",a),Xt(l),i.head.appendChild(l))}function ro(i){return'[src="'+vi(i)+'"]'}function Ea(i){return"script[async]"+i}function uA(i,l,a){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(a.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),sd(d,a.precedence,i),l.instance=d;case"stylesheet":m=io(a.href);var y=i.querySelector(ja(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(a),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,sd(y,a.precedence,i),l.instance=y;case"script":return y=ro(a.src),(m=i.querySelector(Ea(y)))?(l.instance=m,Xt(m),m):(d=a,(m=ji.get(y))&&(d=b({},a),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,sd(d,a.precedence,i));return l.instance}function sd(i,l,a){for(var d=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function tD(i,l,a){if(a===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function nD(i,l,a,d){if(a.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var m=io(d.href),y=l.querySelector(ja(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=od.bind(i),l.then(i,i)),a.state.loading|=4,a.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),a.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,l),(l=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=od.bind(i),l.addEventListener("load",a),l.addEventListener("error",a))}}var pg=0;function iD(i,l){return i.stylesheets&&i.count===0&&cd(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function od(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ad=null;function cd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ad=new Map,l.forEach(rD,i),ad=null,od.call(i))}function rD(i,l){if(!(l.state.loading&4)){var a=ad.get(i);if(a)var d=a.get(null);else{a=new Map,ad.set(i,a);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),bd.exports=qA(),bd.exports}var $A=BA(),I=Sd();const kd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!o&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(o)?o:[o]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},o)=>I.createElement(VA,{ref:o,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _a=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Cd=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const ao=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Nd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Td=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const La=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const jd=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const Ed=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const co=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Od=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Md=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},qa={},Or={},Pg;function uo(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` -`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` -`,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` -`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentb&&(h=" ... ",o=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(o,c).replace(/\t/g,"→")+g,pos:u-o+h.length}}function n(s,o){return t.repeat(" ",o-s.length)+s}function r(s,o){if(o=Object.create(o||null),!s.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+o.linesAfter,f.length).toString().length,w=o.maxLength-(o.indent+v+3);for(let C=1;C<=o.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",o.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` +`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",o.indent)+n((s.line+1).toString(),v)+" | "+A.str+` +`,b+=t.repeat("-",o.indent+v+3+A.pos)+`^ +`;for(let C=1;C<=o.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",o.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Dd=r,Dd}var _d,Gg;function Mn(){if(Gg)return _d;Gg=1;const t=fo(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(o){const c={};return o!==null&&Object.keys(o).forEach(function(u){o[u].forEach(function(f){c[String(f)]=u})}),c}function s(o,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+o+'" YAML type.')}),this.options=c,this.tag=o,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return _d=s,_d}var Ld,Xg;function Jg(){if(Xg)return Ld;Xg=1;const t=fo(),e=Mn();function n(o,c){const u=[];return o[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(o.multi[u.kind].push(u),o.multi.fallback.push(u)):o[u.kind][u.tag]=o.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function o(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ud}var Vd,d0;function f0(){if(d0)return Vd;d0=1;const t=uo(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function o(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Vd=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:o,predicate:f,represent:u,defaultStyle:"lowercase"}),Vd}var Fd,h0;function p0(){return h0||(h0=1,Fd=r0().extend({implicit:[l0(),a0(),u0(),f0()]})),Fd}var Pd,m0;function g0(){return m0||(m0=1,Pd=p0()),Pd}var Yd,y0;function b0(){if(y0)return Yd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function o(c){return c.toISOString()}return Yd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:o}),Yd}var Kd,x0;function v0(){if(x0)return Kd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Kd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Kd}var Gd,w0;function S0(){if(w0)return Gd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function o(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Gd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:s}),Gd}var Xd,A0;function k0(){if(A0)return Xd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(o){if(o===null)return!0;const c={},u=o;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function ae(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function we(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function bt(x,U,pe){let ue,X,k,V,W,ve;const F=x.kind,de=x.result;let le=x.input.charCodeAt(x.position);if(R(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;le!==0;){if(le===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(le===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&ft(x)||pe&&_(le))break;if(O(le))if(V=x.line,W=x.lineStart,ve=x.lineIndent,$e(x,!1,-1),x.lineIndent>=U){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=ve;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))$e(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const ve=x.anchor;let F,de,le,Ae;const Te=Object.create(null);let je,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&ae(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if($e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=ve,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=je=ze=null,de=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=le=!0,x.position++,$e(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ht(x,U,o,!1,!0),Le=x.tag,je=x.result,$e(x,!0,U),Ve=x.input.charCodeAt(x.position),(le||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),$e(x,!0,U),ht(x,U,o,!1,!0),ze=x.result),Ae?He(x,W,Te,Le,je,ze,ue,X,k):de?W.push(He(x,null,Te,Le,je,ze,ue,X,k)):W.push(je),$e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function Se(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,ve=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` -`,de=we&&(k[k.length-2]===` +`,X?1+W:W),X=!0,k=!0,W=0;const le=x.position;for(;!O(de)&&de!==0;)de=x.input.charCodeAt(++x.position);Ce(x,le,x.position,!1)}return!0}function Ne(x,U){const pe=x.tag,ue=x.anchor,X=[];let k=!1;if(x.firstTabInLine!==-1)return!1;x.anchor!==null&&ae(x,x.anchor,X);let V=x.input.charCodeAt(x.position);for(;V!==0&&(x.firstTabInLine!==-1&&(x.position=x.firstTabInLine,q(x,"tab characters must not be used in indentation")),V===45);){const W=x.input.charCodeAt(x.position+1);if(!R(W))break;if(k=!0,x.position++,$e(x,!0,-1)&&x.lineIndent<=U){X.push(null),V=x.input.charCodeAt(x.position);continue}const ve=x.line;if(ht(x,U,u,!1,!0),X.push(x.result),$e(x,!0,-1),V=x.input.charCodeAt(x.position),(x.line===ve||x.lineIndent>U)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(je&&(X=x.line,k=x.lineStart,V=x.position),ht(x,U,f,!0,ue)&&(je?Ae=x.result:Te=x.result),je||(He(x,F,de,le,Ae,Te,X,k,V),le=Ae=Te=null),$e(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const je=k=V=f===pe||u===pe;if(ue&&$e(x,!0,-1)&&(ve=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&le.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&ae(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&($e(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if($e(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,$e(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),$e(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ft(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,$e(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==o||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==o&&k!==f&&k!==u}function He(k,V,W){const ve=qe(k),F=ve&&!Ce(k);return(W?ve:ve&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==o&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function $e(k){return!Ce(k)&&k!==j}function ft(k,V){const W=k.charCodeAt(V);let ve;return W>=55296&&W<=56319&&V+1=56320&&ve<=57343)?(W-55296)*1024+ve-56320+65536:W}function At(k){return/^\n* /.test(k)}const bt=1,Ge=2,Q=3,re=4,Se=5;function Ne(k,V,W,ve,F,de,le,Ae){let Te,je=0,Le=null,ze=!1,Ve=!1;const Dt=ve!==-1;let Fn=-1,jn=Je(ft(k,0))&&$e(ft(k,k.length-1));if(V||le)for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}else{for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),je===u)ze=!0,Dt&&(Ve=Ve||Te-Fn-1>ve&&k[Fn+1]!==" ",Fn=Te);else if(!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}Ve=Ve||Dt&&Te-Fn-1>ve&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!F(k)?bt:de===we?Se:Ge:W>9&&At(k)?Se:le?de===we?Se:Ge:Ve?re:Q}function Be(k,V,W,ve,F){k.dump=(function(){if(V.length===0)return k.quotingType===we?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===we?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=ve||k.flowLevel>-1&&W>=k.flowLevel;function Te(je){return ne(k,je)}switch(Ne(V,Ae,k.indent,le,Te,k.quotingType,k.forceQuotes&&!ve,F)){case bt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+lt(z(V,de));case re:return">"+We(V,k.indent)+lt(z(ti(V,le),de));case Se:return'"'+ht(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",ve=k[k.length-1]===` +`,de=ve&&(k[k.length-2]===` `||k===` -`)?"+":we?"":"-";return W+de+` -`}function vt(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`)?"+":ve?"":"-";return W+de+` +`}function lt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let ve=(function(){let Ae=k.indexOf(` `);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` -`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` -`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` -`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` -`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` -`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ -`)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); -const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` -`)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` -`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`||k[0]===" ",de,le;for(;le=W.exec(k);){const Ae=le[1],Te=le[2];de=Te[0]===" ",ve+=Ae+(!F&&!de&&Te!==""?` +`:"")+Tn(Te,V),F=de}return ve}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let ve,F=0,de,le=0,Ae=0,Te="";for(;ve=W.exec(k);)Ae=ve.index,Ae-F>V&&(de=le>F?le:Ae,Te+=` +`+k.slice(F,de),F=de+1),le=Ae;return Te+=` +`,k.length-F>V&&le>F?Te+=k.slice(F,le)+` +`+k.slice(le+1):Te+=k.slice(F),Te.slice(1)}function ht(k){let V="",W=0;for(let ve=0;ve=65536?ve+=2:ve++){W=ft(k,ve);const F=ce[W];!F&&Re(W)?(V+=k[ve],W>=65536&&(V+=k[ve+1])):V+=F||ae(W)}return V}function ni(k,V,W){let ve="";const F=k.tag;for(let de=0,le=W.length;de"u"&&U(k,V,null,!1,!1))&&(ve!==""&&(ve+=","+(k.condenseFlow?"":" ")),ve+=k.dump)}k.tag=F,k.dump="["+ve+"]"}function Vn(k,V,W,ve){let F="";const de=k.tag;for(let le=0,Ae=W.length;le"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!ve||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let ve="";const F=k.tag,de=Object.keys(W);for(let le=0,Ae=de.length;le1024&&(Te+="? "),Te+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Te+=k.dump,ve+=Te))}k.tag=F,k.dump="{"+ve+"}"}function kt(k,V,W,ve){let F="";const de=k.tag,le=Object.keys(W);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Te=le.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?je+="?":je+="? "),je+=k.dump,Ve&&(je+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?je+=":":je+=": ",je+=k.dump,F+=je)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const ve=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=ve.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Te}return!0}}return!1}function U(k,V,W,ve,F,de,le){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Te=ve;ve&&(ve=k.flowLevel<0||k.flowLevel>V);const je=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(je&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(je&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")ve&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")ve&&k.dump.length!==0?(k.noArrayIndent&&!le&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&Be(k,k.dump,V,de,Te);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],ve=[];ue(k,W,ve);const F=ve.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const o of r){if(s===null||typeof s!="object"||!(o in s))throw new Error(`Reference not found: ${n}`);s=s[o]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const o=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return o[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:o,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),o?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],tf={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(tf),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function nf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...tf[t]]:Cs.filter(n=>t.some(r=>r===n||tf[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function ho(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(o=>typeof o=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function Ba(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const o={...ho(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete o[e]:o[e]=c,o.expand===void 0&&o.sidebarCollapsed===void 0&&o.theme===void 0&&o.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(o))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],o=e[r]??s?.default;if(o===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(o))throw new Error(`Invalid value for server variable ${r}: ${o}`);return o})}function rf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const o=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of o)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return rf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=rf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const o=r.requestBody,c=o?Object.keys(o.content||{})[0]:void 0;if(c){s.contentType=c;const u=o.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function sf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=sf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,o])=>`${s}=${cn(o)}`).join(","):r.flatMap(([s,o])=>[s,cn(o)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=sf(e),o=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(o);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[o(f),o(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=o(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=sf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([o,c])=>[`${t.name}[${o}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(o=>[t.name,cn(o)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const o=Object.entries(s);return r?o.map(([c,u])=>[c,cn(u)]):[[t.name,o.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,o){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,o))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=o[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=rf(t,e,n),o=s.servers[0],c=r.serverUrl||(o?wk(o,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const o=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)o.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&o.push(` --data-raw ${un(t.body)}`),o.join(` \\ +`)}if(e==="javascript"){const o={method:t.method};return n.length&&(o.headers=t.headers),t.body&&(o.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(o,null,2)}); +const data = await response.json();`}if(e==="python"){const o=["import requests","",`url = ${un(t.url)}`];return n.length&&o.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&o.push(`body = ${un(t.body)}`),o.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),o.join(` +`)}if(e==="go"){const o=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${o})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` +`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[o,c]of n)r.push(` .header(${un(o)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var lf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,o=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=ae.value.length,ae=ae.next){var we=ae.value;if(j.length>O.length)return;if(!(we instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=ae.value.length;Re>=ne;)ae=ae.next,ne+=ae.value.length;if(ne-=ae.value.length,he=ne,ae.value instanceof f)continue;for(var Ce=ae;Ce!==j.tail&&(neM.reach&&(M.reach=$e);var ft=ae.prev;He&&(ft=v(j,ft,He),he+=He.length),w(j,ft,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(ae=v(j,ft,At),Je&&v(j,ae,Je),T>1){var bt={cause:G+","+B,reach:$e};g(O,j,R,ae.prev,he,bt),M&&bt.reach>M.reach&&(M.reach=bt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+o+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(o),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:o=!1})=>{const[c,u]=kd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${o?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:o=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(o.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(o);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:o})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:o},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:o})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:o})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function $a(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),o=Object.keys(r);return s.length===o.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function of(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const o=e(),c=of(o,r),u={key:r,value:String(s),enabled:!0};c>=0?o[c]=u:o.push(u)};return{get(r){const s=of(e(),r);return s>=0?e()[s].value:void 0},has(r){return of(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=$a(t.variables||{}),r=$a(t.collectionVariables||{}),s=$a(t.externalVariables||{}),o=$a(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(o,R)?n[R]=o[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return o[R]},has(R){return Object.prototype.hasOwnProperty.call(o,R)},set(R,_){const L=String(_);o[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete o[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(o,M)?o[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` -`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!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:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,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}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{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 n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.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 fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(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(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(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}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(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,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}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 n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` -`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;se.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",o=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${o}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const o=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>o.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:o}}function cf(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function Ia(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&Ia(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&Ia(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&Ia(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&Ia(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const o=Y0(n);if(o.length>0)throw new Error(`This request requires API host execution (${o.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=cf(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,o])=>({key:s,value:o})),body:t.body,contentType:cf(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:cf(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,o])=>({key:s,value:o,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function po(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const o=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return o&&!("$ref"in o)?o:void 0}function lC(t,e,n,r){const o=rC(t,e,n)?.security??t.security??[];if(!o.length)return;const c=o.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=o.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(o.find(f=>Object.keys(f).length===0)??o[0])}function oC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,o=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:o?.authorizationUrl,tokenUrl:o?.tokenUrl,scopes:n.length?n:Object.keys(o?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function aC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let o=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return o;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return o;if(!h)return{...o,auth:{type:"inherit"}};const g=oC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?o=X0(o,"Authorization"):g.type==="apiKey"&&g.in==="header"?o=X0(o,g.key):g.type==="apiKey"&&g.in==="query"&&(o=aC(o,g.key)),{...o,auth:g}):o}function uC(t,e,n,r,s){const o=B0(t,e,n,r);return{request:cC(t,e,n,r,o),serverUrl:r.serverUrl||s}}function Ha(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const uf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function df(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>df(e.key)?{...e,value:uf}:e)}function fC(t){return t?.map(e=>df(e[0])?[e[0],uf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const o=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return df(g)?`${h}=${encodeURIComponent(uf)}`:u}).join("&");return`${o}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Ha(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",o={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete o.responseBody,delete o.responseBodyTruncated,delete o.requestBodyTruncated),o});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Ha(n.auth)})),folders:t.folders.map(n=>({...n,auth:Ha(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Ha(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function mo(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function za(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function Ua(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!Ua(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Va(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function ff(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(ff(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Va(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(ff(t),JSON.stringify(wC(e))):sessionStorage.removeItem(ff(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(Ua))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(Ua))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(Ua))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Va(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Va(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Va(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const o=r.get(s.parentFolderId);(!o||o.collectionId!==s.collectionId||o.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const o=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(o.has(c)){s.parentFolderId=void 0;break}o.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!za(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!za(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!za(t,"runIndex")||!za(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,o])=>[s,o]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=mo();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function oy(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),o=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:o,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:o,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=o=>{if(o.length<=e)return e-=o.length,o;const c=o.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(o=>({...o,value:r(o.value)}))),s.formData&&(s.formData=s.formData.map(o=>({...o,value:r(o.value)}))),{request:s,truncated:n}}function ay(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),o={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:mo()};return{...t,history:[o,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),o=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!o.has(c.id);){if(o.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function hf(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function pf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),o=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,o=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});o=!0}if(!o)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:mo()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let o=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=o.filter(w=>w.key.trim()!==h);v.length!==o.length&&(o=v,c=!0);continue}const g=o.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];o[v]={...o[v],key:h,value:b,enabled:!0},g.length>1&&(o=o.filter((w,A)=>A===v||w.key.trim()!==h))}else o.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:o,updatedAt:mo()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=mo();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const o=e.transaction(tl,"readonly").objectStore(tl).get(t);o.onsuccess=()=>n(AC(t,oy(o.result))),o.onerror=()=>r(o.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const o=n.transaction(tl,"readwrite");o.objectStore(tl).put(Z0(e),t),o.oncomplete=()=>r(),o.onerror=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace")),o.onabort=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),o=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{o.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,o.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function mf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,o=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:mf(O,.5),p95Ms:mf(O,.95),p99Ms:mf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),o=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:o===null?null:new Date(o).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,o=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const gf=zC();function VC(t){gf.record(t)}function FC(){return gf.snapshot()}function PC(){gf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function yf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=yf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Fa(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,o]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${o}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Pa(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&po(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,o=t.hostExecution?.preferHostExecution,c=o===!1?!1:t.preferHostExecution??s??o??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Pa({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:o}of n){const c=s.file;r.append(`formData[${o}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=yf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let o=yf(t.request),c=Fa(t.variables),u=Fa(t.collectionVariables);const f=Fa(t.externalVariables);let h=Fa(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(o=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(o={...o,auth:t.resolveAuth(o.auth)}),o=nC(o,c),w=(o.method||"GET").toUpperCase(),A=o.url;const[j,,,R]=Pa({request:o,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(o);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(o);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function bf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:o="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":o,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Ya(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const o of e)n+=String.fromCharCode(o);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function oN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),o=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",o),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Ya(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function aN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||aN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const o=vy(48),c=await oN(o);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:o}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,o=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:o,scope:typeof n.scope=="string"?n.scope:void 0}}async function Ka(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},o=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&o?s.Authorization=`Basic ${lN(`${o}:${t.clientSecret||""}`)}`:(o&&e.set("client_id",o),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),o=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-osetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}const s=await cN(t,e.windowObject),o=await dN(s,e);if((o.searchParams.get("state")||new URLSearchParams(o.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(o.hash.replace(/^#/,"")),f=o.searchParams.get("error")||u.get("error");if(f){const b=o.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=o.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Ka(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Ya(t);return s&&r.set("scope",s),Ka(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,o]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{o(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{o(!1)}},w=async()=>{o(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{o(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},xf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:o,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>o(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>o({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:o}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>o({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>o({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>o({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>o({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>o({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>o({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>o({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>o({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>o({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>o({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>o({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>o({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>o({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>o({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>o({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>o({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>o({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>o({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let vf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=wf(t,e);for(e+=jy(r);e=0&&Ay(wf(t,c));)o++,c-=2;if(o%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new go(this),o=new go(e);for(let c=n,u=n;;){if(s.next(c),o.next(c),c=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new go(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.text[o],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let o=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ga(o.text,c.text.slice(),0,o.length);if(u.length<=32)r.push(new Vt(u,c.length+o.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ga(this.text,Ga(r.text,Ey(this.text,0,e)),n),o=this.length+r.length-(n-e);return s.length<=32?new Vt(s,o):Hi.from(Vt.split(s,[]),o)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;o<=n&&ce&&c&&(s+=r),eo&&(s+=u.slice(Math.max(0,e-o),n-o)),o=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let o of e)r.push(o),s+=o.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.children[o],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let o=0,c=0;c<=n&&o=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=o&&n<=u){let f=c.replace(e-o,n-o,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;oe&&o&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,o,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,o+=n){if(s==c||o==u)return r;let f=this.children[s],h=e.children[o];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),o=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>o&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ga(t,e,n=0,r=1e9){for(let s=0,o=0,c=!0;o=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],o=this.offsets[r],c=o>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new go(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},go.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const Sf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return o+(e-s);o+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?o:o+f;o+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Af(this,(n,r,s,o,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return kf(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,o=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,o.text),o.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],o=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||Sf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(o,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,o,g,b),s=h,o=g}}}function kf(t,e,n,r=!1){let s=[],o=r?[]:null,c=new yo(t),u=new yo(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),o.forward2(f),c.forward(f)}}}}class yo{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-o.from),n=e.indexOf(r);for(let s=1;so.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Cf=0;class Ue{constructor(e,n,r,s,o){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=Cf++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Nf),!!e.static,e.enables)}of(e){return new Xa([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Nf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Xa{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=Cf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,o=this.id,c=e[o]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Tf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[o];if(A!=null){let C=Za(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),o=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Ja).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let o=r.values[n],c=this.updateF(o,s);return this.compareF(o,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let o=r.facet(Ja),c=s.facet(Ja),u;return(u=o.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Ja.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function bo(t){return e=>new Ly(e,t)}const Qa={highest:bo(Ns.highest),high:bo(Ns.high),default:bo(Ns.default),low:bo(Ns.low),lowest:bo(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new jf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Wa{constructor(e,n,r,s,o,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=o,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],o=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(o[v.facet.id]||(o[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in o){let w=o[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Nf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Wa(e,c,b,u,f,o)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function o(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof jf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)o(h,u);else if(c instanceof jf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),o(h,u)}else if(c instanceof Ly)o(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&o(c.provides,u);else if(c instanceof Xa)r[u].push(c),c.facet.extensions&&o(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(h,u)}}return o(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function xo(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Za(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),Ef=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let o=s.map(n);o&&r.push(o)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,o,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=o,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),o.some(u=>u.type==rn.time)||(this.annotations=o.concat(rn.time.of(Date.now())))}static create(e,n,r,s,o,c){return new rn(e,n,r,s,o,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let o,c;if(r=t[r]))o=t[r++],c=t[r++];else if(s=0;s--){let o=r[s](t);o instanceof rn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof rn?t=o[0]:t=Vy(e,sl(o),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let o=n[s](t);o&&Object.keys(o).length&&(r=Uy(r,Of(e,o,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Mf;try{Mf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Mf)return Mf.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,o,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let o;n?o=e.startState.values.slice():(n=Wa.resolve(r,s,this),o=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(Ef)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),o=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Wa.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||Sf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(Ef)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(o,c)=>c.create(o),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>n.length?r:n[o-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let o of this.facet(qy))for(let c of o(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(o(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Rf(t,e,n={}){let r={};for(let s of t)for(let o of Object.keys(s)){let c=s[o],u=r[o];if(u===void 0)r[o]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,o))r[o]=n[o](u,c);else throw new Error("Config merge conflict for field "+o)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return _f.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Df(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let _f=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function Lf(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class qf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let o=r?this.to:this.from;for(let c=s,u=o.length;;){if(c==u)return c;let f=c+u>>1,h=o[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let o=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,o);oE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}o(C,E,v)}}return{mapped:c.length?new qf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:o=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(Lf)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new vo;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new vo),o.addRange(f,h,g,!1)};for(let f=0;f=o&&e<=o+c.length&&c.between(o,e-o,n-o,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return wo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return wo.from(e).goto(n)}static compare(e,n,r,s,o=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),f=Fy(c,u,r),h=new So(c,f,o),g=new So(u,f,o);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let o=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(o.length!=c.length)return!1;if(!o.length)return!0;let u=Fy(o,c),f=new So(o,u,0).goto(r),h=new So(c,u,0).goto(r);for(;;){if(f.to!=h.to||!$f(f.active,h.active)||f.point&&(!h.point||!Df(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,o=-1){let c=new So(e,null,o).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new vo;for(let s of e instanceof _f?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(Lf);e=r}return t}mt.empty.nextLayer=mt.empty;class vo{finishChunk(e){this.chunks.push(new qf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new vo)).addRange(e,n,r,s)}addInner(e,n,r,s){let o=e-this.lastTo||r.startSide-this.last.endSide;if(s&&o<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let o of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,o));return s.length==1?s[0]:new wo(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),Bf(this.heap,0)}}}function Bf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class So{constructor(e,n,r){this.minPoint=r,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=wo.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){ec(this.active,e),ec(this.activeTo,e),ec(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:o}=this.cursor;for(;n0;)n++;tc(this.active,n,r),tc(this.activeTo,n,s),tc(this.activeRank,n,o),e&&tc(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&ec(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,o){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!o.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Df(t.point,n.point)&&$f(t.activeForPoint(t.to),n.activeForPoint(n.to))||o.comparePoint(u,A,t.point,n.point),g=!1):(g&&o.boundChange(u),A>u&&!$f(t.active,n.active)&&o.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function $f(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;o+=t.charCodeAt(s)==9?n-o%n:1,s=kn(t,s)}return t.length}const If="ͼ",Gy=typeof Symbol>"u"?"__"+If:Symbol.for(If),Hf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ol{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function o(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))o(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");o(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)o(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,If+e.toString(36)}static mount(e,n,r){let s=e[Hf],o=r&&r.nonce;s?o&&s.setNonce(o):s=new IN(e,o),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let o=Jy.get(r);if(o)return e[Hf]=o;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Hf]=this}mount(e,n){let r=this.sheet,s=0,o=0;for(let c=0;c-1&&(this.modules.splice(f,1),o--,f=-1),f==-1){if(this.modules.splice(o++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Ao[dn]=String.fromCharCode(dn);for(var zf in $r)Ao.hasOwnProperty(zf)||(Ao[zf]=$r[zf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ao:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Uf=typeof document<"u"?document:{documentElement:{style:{}}};const Vf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Ff=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),ic=!!(Qy||Ff||Vf),Wy=!ic&&/gecko\/(\d+)/i.test(Dn.userAgent),Pf=!ic&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in Uf.documentElement.style,Yf=!ic&&/Apple Computer/.test(Dn.vendor),eb=Yf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:ic,ie_version:Qy?Uf.documentMode||6:Ff?+Ff[1]:Vf?+Vf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Pf,chrome_version:Pf?+Pf[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Yf,safari_version:Yf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:Uf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Kf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const rc=Object.create(null);function Gf(t,e,n){if(t==e)return!0;t||(t=rc),e||(e=rc);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let o of r)if(o!=n&&(s.indexOf(o)==-1||t[o]!==e[o]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:o,end:c}=nb(e,n);r=(o?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new Co(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}on.none=mt.empty;class ko extends on{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Kf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||rc}eq(e){return this==e||e instanceof ko&&this.tagName==e.tagName&&Gf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}ko.prototype.point=!1;class Co extends on{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Co&&this.spec.class==e.spec.class&&Gf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Co.prototype.mapMode=Wn.TrackBefore,Co.prototype.point=!0;class js extends on{constructor(e,n,r,s,o,c){super(n,r,o,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function al(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class No extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof No&&this.tagName==e.tagName&&Gf(this.attributes,e.attributes)}static create(e){return new No(e.tagName,e.attributes||rc,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}No.prototype.startSide=No.prototype.endSide=-1;function To(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Xf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function jo(t,e){if(!e.anchorNode)return!1;try{return Xf(t,e.anchorNode)}catch{return!1}}function lc(t){return t.nodeType==3?Oo(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Eo(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function oc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,o,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+o)):e.right>v.right-o&&(E=e.right-v.right+o,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let o=t.parentNode;o&&!(o==n.body||(!e||r)&&s);)if(o.nodeType==1)!s&&o.scrollHeight>o.clientHeight&&(s=o),e&&!r&&o.scrollWidth>o.clientWidth&&(r=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:r,y:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ob(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ab(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ob(e))}let cb;function Oo(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),o.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!oc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(o<0||(s!=0?s<0?u.fromn:e[o].level>u.level))&&(o=c)}}if(o<0)throw new RangeError("Index out of range");return o}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?o:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,o=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else o=h,f++}}}function Wf(t,e,n,r,s,o,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Zf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Wf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>o[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==o[h-1].to){if(b)break e;let C=o[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&o[D-1].to==E)E=o[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Zf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var o;let c=r.head-t.from,u=Vi.find(e,c,(o=r.bidiLevel)!==null&&o!==void 0?o:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,o,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=o,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const cc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(uc.of(h=>{let g=h.plugin(u);return g?c(g):on.none})),o&&f.push(o(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class ih{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),rh=Ue.define(),uc=Ue.define(),Eb=Ue.define(),sh=Ue.define(),Mo=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(o=>o instanceof Function?o(t):o),s=[];return mt.spans(r,e.from,e.to,{point(){},span(o,c,u,f){let h=o-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let o of t.state.facet(Rb)){let c=o(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ro=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(o,c,u,f))),this.changedRanges=s}static create(e,n,r){return new dc(e,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}}const oT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return oT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 hc)return e;return null}static get(e){return e.cmTile}}class fc extends Ht{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 n=this.dom,r=null,s,o=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,o&&s!=u.dom&&(o.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,o&&s&&(o.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hc extends fc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,o=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&o++,s=n.pop()}else{let c=r.children[s++];if(c instanceof or)n.push(s),r=c,s=0;else{let u=o+c.length,f=e(c,o);if(f!==void 0)return f;o=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,o,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,c=e-f)}}),!r&&!o)throw new Error("No tile at position "+e);return r&&n<0||!o?{tile:r,offset:s}:{tile:o,offset:c}}}class or extends fc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new or(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends fc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,o=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,o=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?o:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):aT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:o}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,o)):s.domPosFor(o,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function aT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=lc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let o=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(o--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let o=this.dom.getClientRects(),c=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;c=o[f],!(e>0?f==0:f==o.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:o,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(o==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:o}=u.pop(),o++}else{let f=s.children[o],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(lh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(lh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let o=Ht.get(e.text);o&&this.cache.reused.set(o,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let o=this.ensureMarks(n,r);!s&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let o=e.length-1;o>=0;o--){let c=e[o],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(oh,0,32)||new Rs(oh.toDOM(),0,oh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(o),n=o}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(pc,void 0,1);return r&&(r.flags=n),r||new pc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:o,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return o?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const mc=[Rs,fl,Ms,Hn,pc,or,hc];for(let t=0;t[]),this.index=mc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,o=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,o=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,o+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=o=0):c instanceof Hn&&(s.shift(),o=Math.min(o,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,o=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>o),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let o=Ht.get(s);if(s==this.view.contentDOM)break;o instanceof Hn?n.push(o):o?.isLine()?r=o:o instanceof or||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new ko({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Kf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function lh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends sc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const oh=new class extends sc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=on.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 hc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let o=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Oe.ie||Oe.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),o&&!r.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(r=o.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 o=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||r.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&jo(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(o||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!Eo(h.node,h.offset,b.anchorNode,b.anchorOffset)||!Eo(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=To(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=To(e.root),{anchorNode:s,anchorOffset:o}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,o)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let o;if(e==r.dom)o=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?o=e:o=e.nextSibling}if(o==r.dom.firstChild)return s;for(;o&&!Ht.get(o);)o=o.nextSibling;if(!o)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,o=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(o=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,o=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(o&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:o}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof ch?null:s.coordsInWidget(o,n,!0):s.coordsIn(o,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(o,c){if(o.isComposite())for(let u of o.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(o.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof or)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?lc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=o,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=lc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,o;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=lc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,o=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:o}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let o=s==n.viewports.length?null:n.viewports[s],c=o?o.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(on.replace({widget:new ch(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!o)break;r=o.to+1}return on.set(e)}updateDeco(){let e=1,n=this.view.state.facet(uc).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),r=!1,s=this.view.state.facet(sh).map((o,c)=>{let u=typeof o=="function";return u&&(r=!0),u?o(this.view):o});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Db(this.view),c={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),o=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=r,!o)return null;let c=e-o.offset;return{from:c,to:c+o.node.nodeValue.length,node:o.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:o,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(o),f.mapPos(c),o,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class ch extends sc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(s.length==0)return ke.cursor(e);o==0?n=1:o==s.length&&(n=-1);let c=o,u=o;n<0?c=kn(s.text,o,!1):u=kn(s.text,o);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);o+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,o,t.state.tabSize)}function uh(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let o of r.type){if(o.from>e)break;if(!(o.toe)return o;(!s||o.type==fn.Text&&(s.type!=o.type||(n<0?o.frome)))&&(s=o)}}return s||r}return r}function OT(t,e,n,r){let s=uh(t,e.head,e.assoc||-1),o=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(o){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(o.top+o.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,o,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),o=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return o=>{let c=r(o);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,o=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=o<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(o<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*o,E=fh(t,{x:b,y:C},!1,o);if(n?C>f.bottom:Cu:O{if(e>o&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+o:v.bottom>=f+o))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=o&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let o=0;o{let c=r[o]-n,u=r[o+1]-n;return Oo(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Oo(f.dom,0,f.length)).getClientRects()}),o=e.children[s.i],c=r[s.i];return o.isText()?this.scanText(o,c):o.isComposite()?this.scanTile(o,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let o=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:oc(s))||oc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>o)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,c=1,u;if(this.lineSeparator?(o=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(o=u.index,c=u[0].length),this.append(n.slice(r,o<0?n.length:o)),o<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=o+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:o,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=o||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!Xf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Xf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,o=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,o=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:o,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,o=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=o.from,g=null;(c===8||Oe.android&&e.text.length=u&&o.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&b.slice(o.to-u)==e.text.slice(v=e.text.length-(b.length-(o.to-u)))?n={from:o.from,to:o.to,insert:gt.of(e.text.slice(o.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||gc(r,o))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(o.from).toDate.now()-50?n={from:o.from,to:o.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:o.from,to:o.to,insert:gt.of([" "])}),n)return hh(t,n,r,c);if(r&&!gc(r,o)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Mo).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function hh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,o,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,o=s.selection.main,c=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=o.frome.to?s.sliceDoc(e.to,o.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(o.head);let w=o.to-e.to;r=s.changeByRange(A=>{if(A.from==o.from&&A.to==o.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-o.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),o=0;for(;o0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,o-Math.min(c,u));n-=c+f-o}if(c=c?o-n:0;o-=f,u=o+(u-c),c=o}else if(u=u?o-n:0;o-=f,c=o+(c-u),u=o}return{from:o,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||o!=r)&&e.push(new zb(s,o))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function gc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let o in n)if(o!="scroll"){let c=!n[o].handlers.length,u=r[o];u&&c!=!u.handlers.length&&(s.removeEventListener(o,this.handleEvent),u=null),u||s.addEventListener(o,this.handleEvent,{passive:c})}for(let o in r)o!="scroll"&&!n[o]&&s.removeEventListener(o,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,o=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],yc=6;function bc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Mo).map(c=>c(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,o=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+yc?n=-bc(s-e.clientX):e.clientX+f.right>=c-yc&&(n=bc(e.clientX-c)),e.clientY-f.top<=o+yc?r=-bc(o-e.clientY):e.clientY+f.bottom>=u-yc&&(r=bc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=To(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function xc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=xc(t.state,th,e);let{state:n}=t,r,s=1,o=n.toText(e),c=o.lines==n.selection.ranges.length;if(ph!=null&&n.selection.ranges.every(f=>f.empty)&&ph==o.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?o.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=o.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(o);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ab(t.contentDOM);let o=t.root.activeElement;o&&!o.contains(t.contentDOM)&&o.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),o=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:o.from,u=s?s.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(o){o.docChanged&&(n.pos=o.changes.mapPos(n.pos),s=s.map(o.changes))},get(o,c,u){let f=t.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let o=s.posAtStart,c=o+s.length;(o>=n.to||c<=n.from)&&(n=ke.undirectionalRange(o,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",xc(t.state,nh,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=xc(t.state,th,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,c=r&&o&>(t,e)?{from:o.from,to:o.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,o=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),o()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let c=t.doc.lineAt(o);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:xc(t,nh,e.join(t.lineBreak)),ranges:n,linewise:r}}let ph=null;Mi.copy=Mi.cut=(t,e)=>{if(!jo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;ph=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=Gb?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let o=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(o&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return hh(t,{from:f,to:h,insert:t.state.toText(o)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(o=>o.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>o+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ox(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=o,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>vc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let o=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=o.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:o.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fo*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(o>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,o-=u.size}else break;else if(s=o&&c(this.lineAt(0,Rt.ByPos,r,s,o))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ax{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,o=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);c=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else c=this.height/o;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:o,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let o=r[r.length-1];o instanceof hn?r[r.length-1]=new hn(o.length+s):r.push(null,new hn(s-1))}if(e>0){let o=r[0];o instanceof hn?r[0]=new hn(e+o.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let o=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=o&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=vc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=o&&c.push(null,new hn(o-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=vc||Math.abs(f-this.heightMetrics(e,n).perLine)>=vc)&&(ml=!0),wc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class oj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let o=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,o).join(h)}forEachLine(e,n,r,s,o,c){let u=s+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,o);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let o=[];e>0&&this.decomposeLeft(e,o);let c=o.length;for(let u of r)o.push(u);if(e>0&&cx(o,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=wc(this.left,e),this.right=wc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:o,right:c}=this,u=n+o.length+this.break,f=null;return s&&s.from<=n+o.length&&s.more?f=o=o.updateHeight(e,n,r,s):o.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(o,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const aj=5;class mh{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=aj)&&this.addLineDeco(s,o,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();o=Math.max(o,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:o-n.left,right:Math.max(o,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class gh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=on.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:o,to:c})=>s>=o&&s<=c)){let{from:o,to:c}=this.lineBlockAt(s);e.push(new Sc(o,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new yh(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(_o(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,o=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ox(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,o=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(o,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ox();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,o=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new Sc(s.lineAt(c-r*1e3,Rt.ByHeight,o,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,o,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,o,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&o>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new gh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(o,c){r.push({from:o,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||_o(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||_o(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return _o(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}}class Sc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,o=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),o+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:o,to:c}=e[s],u=c-o;if(r<=u)return o+r;r-=u}}function kc(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(uc).filter(r=>typeof r!="function"),n=t.facet(sh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class yh{constructor(e,n,r){let s=0,o=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-o)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),o=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let o=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function _o(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>_o(s,e)):t._content)}const Cc=Ue.define({combine:t=>t.join(" ")}),bh=Ue.define({combine:t=>t.indexOf(!0)>-1}),xh=ol.newName(),hx=ol.newName(),px=ol.newName(),mx={"&light":"."+hx,"&dark":"."+px};function vh(t,e,n){return new ol(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=vh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),wh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!jo(this.dom,s))return;let o=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&Eo(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=To(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=jo(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&cl(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let o of e){let c=this.readMutation(o);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&jo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!gc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return Eo(c.node,c.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:o,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&othis.to&&(f=o);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));gc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);hh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],o=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let o of r.getTextFormats()){let c=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),h=this.toEditorPos(o.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=To(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((o,c,u,f,h)=>{if(r)return;let g=h.length-(c-o);if(s&&c>=s.to)if(s.from==o&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(o+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(othis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(o=>r(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(cc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new ih(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,o=this.state;for(let v of e){if(v.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=v.state}if(this.destroyed){this.viewState.state=o;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(o,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(g=null)):this.observer.clear(),o.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(o);s=dc.create(this,o,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(cc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Nc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Cc)!=s.state.facet(Cc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(eh))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new ih(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let o of r){let c=n.indexOf(o);if(c<0)s.push(new ih(o));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))o=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);o=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=dc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?o<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(eh))f(n)}get themeClasses(){return xh+" "+(this.state.facet(bh)?px:hx)+" "+this.state.facet(Cc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,rh,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),o=tb(this.dom,this.editorAttrs,e);return s||o});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let e=this.state.facet(Xe.cspNonce);ol.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return dh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return dh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),o=r[n?r.length-1:0];return ke.cursor(o.side(n,s)+e.from,o.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return dh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=fh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),fh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,o.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==n&&(o.fresh||mb(o.isolates,r=Mb(this,e))))return o.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Nc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(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,n={}){var r,s,o,c;return cc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(o=n.yMargin)!==null&&o!==void 0?o:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return cc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=ol.newName(),s=[Cc.of(r),Ro.of(vh(`.${r}`,e))];return n&&n.dark&&s.push(bh.of(!0)),s}static baseTheme(e){return Qa.lowest(Ro.of(vh("."+xh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ro,Xe.inputHandler=Sb,Xe.clipboardInputFilter=th,Xe.clipboardOutputFilter=nh,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=eh,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=uc,Xe.blockWrappers=Eb,Xe.outerDecorations=sh,Xe.atomicRanges=Mo,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=bh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=rh,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Nc{constructor(e,n,r,s,o,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=o,this.order=c}static update(e,n){if(n.empty&&!e.some(o=>o.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let o=Math.max(0,e.length-10);o=0;s--){let o=r[s],c=typeof o=="function"?o(t):o;c&&Kf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,o,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},o=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,Sh))}let f=c[e]||c.key;if(f)for(let h of u)o(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&o(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let Sh=null;function Ej(t,e,n,r){Sh=e;let s=UN(e),o=kN(s,0),c=CN(o)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Tc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Tc(A,e,!0)])||e.shiftKey&&(C=Ao[e.keyCode])!=s&&C!=A&&v(w[u+Tc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Tc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),Sh=null,f}class Ds{constructor(e,n,r,s,o){this.className=e,this.left=n,this.top=r,this.width=s,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let o=Sx(e);return[new Ds(n,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let o=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:o.left+1,y:c}),f=t.posAtCoords({x:o.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),o=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=uh(t,r,1),A=uh(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;we>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(we,q),L==null&&we>=be,ae.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(jc)!=e.state.facet(jc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(jc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const jc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),jc.of(t)]}const gl=Ue.define({combine(t){return Rf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(o&&Oe.ios&&n.iosSelectionHandles)){let c=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let o of Ds.forRange(t,"cm-selectionBackground",s))e.push(o);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Qa.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=on.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return on.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const Ec=Ue.define(),Hj=Ue.define(),Oc=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Oc).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Ec),this.view.viewport.from),r=[],s=this.gutters.map(o=>new Vj(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let c=!0;for(let u of o.type)if(u.type==fn.Text&&c){Ah(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(o.type==fn.Text){Ah(n,r,o.from);for(let c of s)c.line(this.view,o,r)}else if(o.widget)for(let c of s)c.widget(this.view,o);for(let o of s)o.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Oc),n=t.state.facet(Oc),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Ec),t.state.facet(Ec),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let o of n){let c=e.indexOf(o);c<0?s.push(new Ox(this.view,o)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let o of this.gutters)o.dom.remove(),s.indexOf(o)<0&&o.destroy();for(let o of s)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Ah(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,o=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,o,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,o,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Ah(this.cursor,s,n.from),r.length&&(s=s.concat(r));let o=this.gutter.config.lineMarker(e,n,s);o&&s.unshift(o);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let o of e.state.facet(Hj)){let c=o(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let o=s.target,c;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let o=0,c=0;;){let u=c,f=oo(u,f,h)||c(u,f,h):c}return r}})}});class kh extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ch(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Oc.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new kh(Ch(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let o=s(e,n,r);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new kh(Ch(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=Ch(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new kh(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Nh{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class Lo{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(s)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return s}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 n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),o=-1;o<(s?s.length:0);o++){let c=n[o<0?r.name:s[o]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Mc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,o){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,o&&o.length){this.props=Object.create(null);for(let[c,u]of o)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=Lo.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Eh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Mc.get(this)||this.topNode,o=new Eh(s);return o.moveTo(e,n),Mc.set(this,o._tree),o}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=qo(Mc.get(this)||this.topNode,e,n,!1);return Mc.set(this,r),r}resolveInner(e,n=0){let r=qo(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:o=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=o&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Mh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Th{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Th(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,o=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function qo(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(o&Pt.EnterBracketed&&g instanceof pn&&(v=Lo.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(o&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(o&Pt.IncludeAnonymous||!g.type.isAnonymous||Oh(g)){let w;if(!(o&Pt.IgnoreMounts)&&(w=Lo.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return o&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,o)}}}if(o&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=Lo.get(this._tree))&&s.overlay){let o=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=o:u=o:f>o))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return o}for(;;){if(r!=null&&s.type.is(r))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return r==null?o:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,o=r.buffer[this.index+3];if(o>s){let c=r.buffer[this.index+1];e.push(r.slice(s,o,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let o=1;on.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+o.from,-1,o);(s||(s=[r])).push(qo(u,e,n,!1))}}return s?Ix(s):r}class Eh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let o=n+e,c=e<0?-1:r._tree.children.length;o!=c;o+=e){let u=r._tree.children[o];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Oh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=o+1;break e}s=this.stack[--o]}for(let s=r;s=0;o--){if(o<0)return jh(this._tree,e,s);let c=r[n.buffer[this.stack[o]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Oh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Oh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:o=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Th(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=o[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],ae,he,we=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);ae=new Ur(T,be-he.start,r),we=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);ae=Mh(J,z,me,0,z.length,0,be-ee,qe,qe)}else ae=C(J,z,me,be-ee,ge-be,q)}M.push(ae),G.push(we)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(yt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[yt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[yt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Rc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Rc(t,r)}Hx.set(e,n)}return n}function Mh(t,e,n,r,s,o,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Mh(t,A,C,R,j,_,M,null,f))}v.push(_+O-o)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,o=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(o?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let o of n)o.to>e.length&&s.push(o);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],o=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=onew Nh(s.from,s.to)):[new Nh(0,0)]:[new Nh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let o=s.advance();if(o)return o}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let o of n.set)s.set.push(o);return s}static defineModifier(e){let n=new Dc(e);return r=>r.modified.indexOf(n)>-1?r:Dc.get(r.base||r,r.modified.concat(n).sort((s,o)=>s.id-o.id))}}let lE=0;class Dc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&oE(n,u.modified));if(r)return r;let s=[],o=new yi(e.name,s,e,n);for(let u of n)u.instances.push(o);let c=aE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Dc.get(u,f));return o}}function oE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function aE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let o=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(o.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=o.length-1,h=o[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new _c(r,c,f>0?o.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let o=new _c(s.tags,s.mode,s.context);n?n.next=o:r=o,n=o}return r}});class _c{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of o)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const Ee=yi.define,Lc=Ee(),Fr=Ee(),zx=Ee(Fr),Ux=Ee(Fr),Pr=Ee(),qc=Ee(Pr),Rh=Ee(Pr),Yi=Ee(),Ls=Ee(Yi),Ki=Ee(),Gi=Ee(),Dh=Ee(),Bo=Ee(Dh),Bc=Ee(),rt={comment:Lc,lineComment:Ee(Lc),blockComment:Ee(Lc),docComment:Ee(Lc),name:Fr,variableName:Ee(Fr),typeName:zx,tagName:Ee(zx),propertyName:Ux,attributeName:Ee(Ux),className:Ee(Fr),labelName:Ee(Fr),namespace:Ee(Fr),macroName:Ee(Fr),literal:Pr,string:qc,docString:Ee(qc),character:Ee(qc),attributeValue:Ee(qc),number:Rh,integer:Ee(Rh),float:Ee(Rh),bool:Ee(Pr),regexp:Ee(Pr),escape:Ee(Pr),color:Ee(Pr),url:Ee(Pr),keyword:Ki,self:Ee(Ki),null:Ee(Ki),atom:Ee(Ki),unit:Ee(Ki),modifier:Ee(Ki),operatorKeyword:Ee(Ki),controlKeyword:Ee(Ki),definitionKeyword:Ee(Ki),moduleKeyword:Ee(Ki),operator:Gi,derefOperator:Ee(Gi),arithmeticOperator:Ee(Gi),logicOperator:Ee(Gi),bitwiseOperator:Ee(Gi),compareOperator:Ee(Gi),updateOperator:Ee(Gi),definitionOperator:Ee(Gi),typeOperator:Ee(Gi),controlOperator:Ee(Gi),punctuation:Dh,separator:Ee(Dh),bracket:Bo,angleBracket:Ee(Bo),squareBracket:Ee(Bo),paren:Ee(Bo),brace:Ee(Bo),content:Yi,heading:Ls,heading1:Ee(Ls),heading2:Ee(Ls),heading3:Ee(Ls),heading4:Ee(Ls),heading5:Ee(Ls),heading6:Ee(Ls),contentSeparator:Ee(Yi),list:Ee(Yi),quote:Ee(Yi),emphasis:Ee(Yi),strong:Ee(Yi),link:Ee(Yi),monospace:Ee(Yi),strikethrough:Ee(Yi),inserted:Ee(),deleted:Ee(),changed:Ee(),invalid:Ee(),meta:Bc,documentMeta:Ee(Bc),annotation:Ee(Bc),processingInstruction:Ee(Bc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var _h;const $c=new yt,fE=new yt;class ar{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((o,c,u)=>{let f=Vx(o,c,u),h=f.type.prop($c);if(!h)return[];let g=o.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,o)){let A=o.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop($c)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(o,c)=>{if(o.prop($c)==this.data){r.push({from:c,to:c+o.length});return}let u=o.prop(yt.mounted);if(u){if(u.tree.prop($c)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+o.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let $o=null;class Ic{constructor(e,n,r=[],s,o,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=o,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Ic(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=$o;$o=this;try{return e()}finally{$o=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:o,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,o=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let o=s[0].from,c=s[s.length-1].to;return{parsedPos:o,advance(){let f=$o;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return $o}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Ic.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}ar.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(ar.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Lh=typeof navigator<"u"&&(!((_h=navigator.scheduling)===null||_h===void 0)&&_h.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=o.context.work(()=>Lh&&Lh()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ar.setState.of(new bl(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[ar.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),qh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Hc(t){let e=t.facet(qh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function zc(t,e){let n="",r=t.tabSize,s=t.facet(qh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let o=0;o=e?yE(t,n,e):null}class Uc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Hc(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:o}=this.options;return s!=null&&s>=r.from&&s<=r.to?o&&s==e?{text:"",from:e}:(n<0?s-1&&(o+=c-this.countColumn(r,r.search(/\S|$/))),o}countColumn(e,n=e.length){return nc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),o=this.options.overrideIndentation;if(o){let c=o(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let o=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)o.push(c);for(let c=o.length-1;c>=0;c--)r={node:o[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(Bh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,o=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,o&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class Bh extends Uc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Bh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(n.from),c=s==null||s<=o.from?o.to:Math.min(o.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let o=t.textAfter,c=o.match(/^\s*/)[0].length,u=r&&o.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function $h(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function Ih(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,o=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=$h(f.type,n,o);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,o)}}return jE(t,e,n,c,u.type,s,o)}function TE(t,e,n,r,s,o,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&o.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=o;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Hh(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Hh(h,`Modifier ${h} used at start of tag`):f.length?Hh(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Hh(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),o=Jx[s];if(o)return o.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Uh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function zh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=zh($E,0),_E=zh(Qx,0),LE=zh((t,e)=>Qx(t,e,BE(e)),0);function Uh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Io=50;function qE(t,{open:e,close:n},r,s){let o=t.sliceDoc(r-Io,r),c=t.sliceDoc(s,s+Io),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(c)[0].length,h=o.length-u;if(o.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*Io?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+Io),b=t.sliceDoc(s-Io,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(o=>Uh(e,o.from).block);if(!r.every(o=>o))return null;let s=n.map((o,c)=>qE(e,r[c],o.from,o.to));if(t!=2&&!s.every(o=>o))return{changes:e.changes(n.map((o,c)=>s[c]?[]:[{from:o.from,insert:r[c].open+" "},{from:o.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(o=>o)){let o=[];for(let c=0,u;cs&&(o==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;vo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&o.push({from:u.from+h,insert:f+" "});let c=e.changes(o);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,o.push({from:h,to:g})}return{changes:o}}return null}const Vh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Rf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Vh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Fc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return o?t=t.addChanges(o,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Fh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Vc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let o=s.pop(t,n,e);return o?(r(o),!0):!1}}const ev=Vc(0,!1),Fh=Vc(1,!1),UE=Vc(0,!0),VE=Vc(1,!0);class zn{constructor(e,n,r,s,o){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=o}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let o=s(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Fc(t,e,n,r){let s=e+1>n+20?e-n-1:0,o=t.slice(s,e);return o.push(r),o}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,o)=>n.push(s,o)),e.iterChangedRanges((s,o,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Fc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Ph(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let o=t.slice(0,n);return o[n-1]=s,o}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(o):o;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(o),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,o){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Pc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function ov(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Pc(n,e))}const JE=t=>ov(t,!Nn(t)),QE=t=>ov(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let o=r.type.prop(s),c,u;return o&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Yc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Yc(t.state,e,Nn(t)));function av(t,e){return _i(t,n=>{if(!n.empty)return Pc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>av(t,!1),uv=t=>av(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Pc(c,e));if(s.eq(r.selection))return!1;let o;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Yh=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(s=ke.cursor(r.from+o))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function oO(t,e,n){let r=!1,s=wl(t.selection,o=>{let c=vl(t,o.head,-1)||vl(t,o.head,1)||o.head>0&&vl(t,o.head-1,1)||o.headoO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let o=n(s);return ke.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Yc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Yc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Gc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),o=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let o of n.selection.ranges){let c=n.doc.lineAt(o.head);if(e?c.to0)for(let u=o;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ho(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(o=>{let{from:c,to:u}=o;if(c==u){let f=e(o);fc&&(n="delete.forward",f=Kc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Kc(t,c,!1),u=Kc(t,u,!0);return c==u?{range:o}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,o)=>{se&&(e=n?o:s)});return e}const Ev=(t,e,n)=>Ho(t,r=>{let s=r.from,{state:o}=t,c=o.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ho(t,n=>{let r=n.head,{state:s}=t,o=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?o.to:o.from)){r==n.head&&o.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(o.text,r-o.from,e)+o.from,h=o.text.slice(Math.min(r,f)-o.from,Math.max(r,f)-o.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ho(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headHo(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ho(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,o=t.doc.lineAt(s),c=s==o.from?s-1:kn(o.text,s-o.from,!1)+o.from,u=s==o.to?s+1:kn(o.text,s-o.from,!0)+o.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=o.to,c.ranges.push(r)}else e.push({from:s.from,to:o.to,ranges:[r]});n=o.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let o of Gc(t)){if(n?o.to==t.doc.length:o.from==0)continue;let c=t.doc.lineAt(n?o.to+1:o.from-1),u=c.length+1;if(n){r.push({from:o.to,to:c.to},{from:o.from,insert:c.text+t.lineBreak});for(let f of o.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:o.from},{from:o.to,insert:t.lineBreak+c.text});for(let f of o.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let o of Gc(t))n?r.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):r.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Gc(e).map(({from:s,to:o})=>(s>0?s--:o{let o;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(o=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,o)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),o;return r&&s&&r.to<=e&&s.from>=e&&(o=r.type.prop(yt.closedBy))&&o.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:o,to:c}=s,u=e.doc.lineAt(o),f=!t&&o==c&&qO(e,o);t&&(o=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new Uc(e,{simulateBreak:o,simulateDoubleBreak:!!f}),g=Yx(h,o);for(g==null&&(g=nc(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));cu.from&&o{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let o=t.changes(s);return{changes:s,range:ke.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Uc(t,{overrideIndentation:o=>{let c=n[o];return c??-1}}),s=Gh(t,(o,c,u)=>{let f=Yx(r,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let h=/^\s*/.exec(o.text)[0],g=zc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(qh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let o=nc(s,t.tabSize),c=0,u=zc(t,Math.max(0,o-Hc(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Kh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Yh}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Yh,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Yh,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Kh,shift:Kh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:aO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:o}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),o!==void 0&&(c["aria-expanded"]=String(o)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const zo=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:o=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,ae=J)=>{const he=O.current;if(!he)return;const we=he.state.doc.length,T=Math.max(0,Math.min(J,we)),z=Math.max(0,Math.min(ae,we));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const ae=O.current;if(!ae)return null;const he=Math.max(0,Math.min(J,ae.state.doc.length)),we=ae.coordsAtPos(he);return we?{left:we.left,right:we.right,top:we.top,bottom:we.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,ae=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Qa.highest(Xe.domEventHandlers({keydown:we=>(_.current?.(we),we.defaultPrevented)})),Xe.updateListener.of(we=>{we.docChanged&&!L.current&&j.current(we.state.doc.toString()),(we.selectionSet||we.docChanged)&&R.current?.(we.state.selection.main.head)})]}),he=new Xe({state:ae,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const ae=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(ae.anchor,e.length),head:Math.min(ae.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(o,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});zo.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Xh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(o,c)=>n(e.map((u,f)=>f===o?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((o,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:o.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:o.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:o.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||po(t),s=n==="dark",o=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Xh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(zo,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:o,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Xh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${o}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${o}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Xh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${o}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(zo,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(zo,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const o=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,o]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>o(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>o("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} -});`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;a{const u=a.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` +`).map(o=>{const u=o.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` `)}function Pv(t,e){return t.slice(0,Math.max(0,Math.min(e,t.length))).replace(/\r\n?/g,` `).length}function Yv(t,e,n){const r=t.split(` `),s=e.split(` -`),a=t.slice(0,Math.max(0,Math.min(n,t.length))),c=a.split(` -`).length-1,u=a.lastIndexOf(` -`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),o=t.slice(0,Math.max(0,Math.min(n,t.length))),c=o.split(` +`).length-1,u=o.lastIndexOf(` +`),f=o.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),o=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(o,s.length),selectionEnd:Math.min(Math.max(o,c),s.length)}}const Jh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Jh,"flex.collection":Jh,"flex.variables":Jh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,o)=>s.localeCompare(o)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,o]of r){const c=n.match(s);if(c)return{path:o,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function o3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function a3(t,e,n,r={},s=!1){const o=Math.max(0,Math.min(e,t.length)),c=t.slice(0,o),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:o-u.prefix.length,to:o,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:o-f.prefix.length,to:o,items:v}:null}const h=o3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:o-h.prefix.length,to:o,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:o-g.length,to:o,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:o={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,ae=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,ae))})},j=(B,K,ee=!1)=>{const be=a3(B,K,r,o,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(ao,{className:"h-3.5 w-3.5"}):p.jsx(Od,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(zo,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Xc="API-host execute route",Jc="the execute path";function Qc(t,e){return`${Xc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Qc("was unauthorized",`documentation authentication for ${Jc}`):t===403?Qc("was rejected",`CSRF, same-origin, and authorization middleware for ${Jc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Xc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Xc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Jc}.`:Qc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const o=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await o.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return o.status===429||o.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):o.redirected?Qc("was redirected",`authentication middleware for ${Jc}`):o.ok?`${Xc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(o.status,o.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Qh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Qh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Qh(n);if(!r)return t;const s=Qh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const o=new URL(t),c=`${o.pathname==="/"?"":o.pathname}${o.search}${o.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||po(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:o}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${o}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${o}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),o=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:o}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:o="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",ae=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",we=J||ae||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(ae),[qe,He]=I.useState(he),Je=I.useRef(we),$e=I.useRef(we),[ft,At]=I.useState(null),[bt,Ge]=I.useState(),[Q,re]=I.useState(null),[Se,Ne]=I.useState(null),[Be,We]=I.useState([]),[lt,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),ve=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Te=["GET","HEAD"].includes(Ae),je=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${je}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&o!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Fo=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=po(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Fo},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>o==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${le}-script-tab-${se}`,En=se=>`${le}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&o!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),ve.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Po=E?E(T.auth):T.auth,Qr=Pa({request:{...T,auth:Po},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),lu=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(ft,{...T,auth:Po},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ht(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Be.filter(se=>se.passed).length,Yo=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Yo&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${je}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||$e.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${je}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{ve.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Te&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:je,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:je,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(xf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:o==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>lu(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),o==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${je}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),o==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${je}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(bf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Yo,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(co,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),Se&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Se]}),ft&&p.jsx(QO,{response:ft,theme:s,curlCommand:bt,advanced:o==="advanced"}),Be.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Be.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Be.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),lt.length>0&&p.jsx(Rr,{code:lt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Wh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:o,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(o,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(o||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>hf(K),[K]),ae=t1(D,_)!==t1(w.request,A),he=C==="advanced",we=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Wh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(bf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${we}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&ae&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(La,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${we}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Wh("tab",ne)},onScriptTabChange:ne=>{B(ne),Wh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>pf(Ce,ne))})]})};function Wc(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(t){if(!t)return"";try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"?e.origin:""}catch{return""}}function T3(t,e,n,r){const s=e.startsWith("/")?e:`/${e}`;return{method:t.toUpperCase(),url:n?`${n}${s}`:s,auth:{type:"none"},...r?{hostExecution:{preferHostExecution:!0}}:{}}}function j3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function E3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const O3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:o,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=j3(),h=o??nf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L){if(!(c?.runtimeOnly?.some(lt=>lt.path===e&<.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(lt=>lt.code==="runtime.operation-undocumented"&<.location.path===e&<.location.method?.toUpperCase()===n.toUpperCase())))return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const Se=N3(c?.serverOrigin),Ne=s.tryIt?.hostExecution,Be=Ne?.available===!0&&Ne.preferHostExecution!==!1,We=()=>u?.({request:T3(n,e,Se,Be),serverUrl:Se||void 0,scripts:{preRequest:"",tests:""},requestTab:"params",scriptTab:"pre-request"});return p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsxs("dl",{className:`mt-4 space-y-3 text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:[p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.contractEvidence||"Contract"}),p.jsx("dd",{children:ce?.contractNotDeclared||"OpenAPI does not declare this operation."})]}),p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.runtimeEvidence||"Runtime"}),p.jsx("dd",{children:ce?.runtimeRouteUndocumented||`${n.toUpperCase()} ${e} is registered by the running service.`})]})]}),u&&p.jsxs("button",{type:"button",className:"mt-4 inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:We,children:[p.jsx(La,{className:"h-4 w-4"}),ce?.openApiClient||"Open in API Client"]})]})}if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",ae=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,we={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const Se=!A.has(re);w(Ne=>{const Be=new Set(Ne.key===b?Ne.sections:g);return Be.has(re)?Be.delete(re):Be.add(re),{key:b,sections:Be}}),re==="tryIt"&&E3("tryIt",Se?"1":void 0)},He=(re,Se,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Se}-heading`,children:[p.jsxs("button",{type:"button",id:`${Se}-heading`,"aria-expanded":A.has(Se),onClick:()=>qe(Se),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Se)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(Se)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},$e=(re,Se)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=ae.indexOf(Se),Be=re.key==="Home"?ae[0]:re.key==="End"?ae[ae.length-1]:re.key==="ArrowRight"?ae[(Ne+1)%ae.length]:ae[(Ne-1+ae.length)%ae.length];Je(Be)},ft=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wc(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,bt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{ft()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Cd,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&bt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:bt.map(([re,Se])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof Se=="string"?Se:JSON.stringify(Se)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...we})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,Se])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),Se.schema&&p.jsx(Dr,{spec:t,schema:Se.schema,theme:r,...we}),Se.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Se.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,Se])=>{const Ne=In.isReference(Se)?In.resolveReference(t,Se.$ref):Se;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([Be,We])=>{const lt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:Be}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...we})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),lt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(lt.value??lt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Be)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:ae.map(re=>p.jsx("button",{ref:Se=>{R.current[re]=Se},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:Se=>$e(Se,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function M3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function R3(t,e){let n=M3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function D3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const o of In.getHttpMethods(s)){const c=s[o];n.push({path:r,method:o,operation:c,score:R3(c,o),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const _3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",o=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=D3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:o,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${o}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${o}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${o}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${o}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${o}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${o}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(La,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(La,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${o}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${o}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const L3=typeof n1>"u"?{commit:"unknown"}:n1,q3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=L3,o=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),o]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},B3=(t,e,n)=>t==="dark"?n:e,$3="Runtime intelligence returned an invalid snapshot.",I3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),H3=new Set(["error","warning","info"]),z3=new Set(["pass","warn","fail","partial"]);function sn(){throw new Error($3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&sn(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&sn(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];sn()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&sn(),n}function U3(t){return Ji(t)||sn(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||sn(),t.map(U3)}function V3(t){(!Ji(t)||!Ji(t.location))&&sn();const e=Un(t,"code"),n=Un(t,"severity");(!I3.has(e)||!H3.has(n)||t.location.kind!=="operation")&&sn();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const o=i1(t,"expected");o!==void 0&&(r.expected=o);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),t.disposition!==void 0&&(t.disposition!=="acknowledged"&&sn(),r.disposition="acknowledged"),r}function F3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&sn();const e=Un(t,"status");z3.has(e)||sn();const n=t.findings.map(V3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&sn();const o=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==o&&sn(),{status:e,complete:t.complete,findings:n,summary:r}}function P3(t){Ji(t)||sn(),(!Ji(t.runtime)||!Ji(t.summary))&&sn(),typeof t.discoveryComplete!="boolean"&&sn();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const o=Zh(t,"serverOrigin");if(o&&(r.serverOrigin=o),t.server!==void 0){Ji(t.server)||sn();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&sn(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||sn(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=F3(t.validation)),r}const Y3=60;function K3(t,e,n=Y3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function G3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const X3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:o,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:o},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,o,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=K3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=G3(C.current);if(!J.length)return;const ae=J[0],he=J[J.length-1],we=document.activeElement;q.shiftKey&&(we===ae||!C.current.contains(we))?(q.preventDefault(),he.focus()):!q.shiftKey&&(we===he||!C.current.contains(we))&&(q.preventDefault(),ae.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},J3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function Q3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:o,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=W3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(o)?o.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:Q3(o),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(o)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),J3[D]]},D))]}),o!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function eM(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const tM=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:o,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),o();return}if(j.key!=="Tab"||!f.current)return;const R=eM(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,o]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:o}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:o,children:p.jsx(Md,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(nM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),o())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function nM({result:t,theme:e,messages:n,onSelect:r}){const o=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:o,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code}),u.disposition==="acknowledged"&&p.jsx("span",{children:n?.acknowledgedFinding||"acknowledged"})]}),p.jsx("div",{className:`mt-1 text-xs ${o}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${o}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${o}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:o,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>o?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>o(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function iM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Zc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function eu(t){return Array.isArray(t)?`[${t.map(eu).join(",")}]`:Zc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${eu(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function rM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function o1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){o1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function sM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function a1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let o=n?s.get(n):void 0;for(;o&&!r.has(o.id);)r.add(o.id),o=o.parentFolderId?s.get(o.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const o of t.folders)o.collectionId!==e||!o.parentFolderId||r.has(o.id)||r.has(o.parentFolderId)&&(r.add(o.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const o=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))o.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&o.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function lM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[sM(r)],activeEnvironmentId:r.id}}function oM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=a1(r,e),o=f1(r,e);h1(o,e);const c=lM(r,n.environmentId),u={version:6,collections:[rM(s)],folders:d1(r,e),requests:o,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function aM(t){if(!Zc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function tu(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function cM(t,e){const n=a1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(o=>o.id===e.folderId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(o=>o.id===e.requestId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function uM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function dM(t){if(!Zc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Zc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=aM(t.scope),n=uM(t.workspace),r=oy(n);if(eu(n)!==eu(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");tu(r.collections,"collection"),tu(r.folders,"folder"),tu(r.requests,"request"),tu(r.environments,"environment"),cM(r,e);for(const s of r.requests)o1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function fM(t){return`${JSON.stringify(dM(t),null,2)} +`}function hM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let o=!0;for(;o;){o=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),o=!0)}return s}function Sl(t,e,n){const r=hM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function pM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(o=>o.id===e)?.name||"Deleted collection";if(!n)return r;const s=pM(t.folders.filter(o=>o.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function mM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function gM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const o=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=pf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&mM(E);let j;E.result&&!D&&(s=ay(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(o.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=o.filter(g=>g.cancelled).length,h=o.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:o.length,passed:u,failed:h,cancelled:f,stopped:c,items:o,workspace:s}}function Gr(){return new Date().toISOString()}function yM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const bM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:o,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,Se=(Ne,Be)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:Be}),Se(We.id,Be+1))})};return Se(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),Se(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],Se=new Set;let Ne=K.get(Q);for(;Ne&&!Se.has(Ne.id);)Se.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const Se=oM(h,Q),Ne=new Blob([fM(Se)],{type:"application/json;charset=utf-8"}),Be=URL.createObjectURL(Ne),We=document.createElement("a");We.href=Be,We.download=yM(re),We.click(),setTimeout(()=>URL.revokeObjectURL(Be),0),L("")}catch(Se){L(Se instanceof Error?Se.message:String(Se))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),Se=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:Se,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(Se),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(Se=>({...Se,folders:Se.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},ae=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(Se=>Se.id===M.id?{...Se,variables:[...Se.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:Se)}))},he=(Q,re)=>{if(!M)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Be=>Be.id===M.id?{...Be,variables:Be.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:Se}:Be)}))},we=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter(Be=>Be.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),Se=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:Se,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(Se),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map(Be=>Be.id===j?{...Be,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:Be)}));return}const Se={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,Se]})),R(Se.id),O(Q)},me=Q=>{const re=h.requests.find(Se=>Se.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(Se=>Se.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(Se=>Se.id===Q);g(Se=>LC(Se,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",$e=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),ft=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=be(Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return p.jsxs(kd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Be}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${Be} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},Be),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(lt=>ft(lt,re+1,Ne))]},Q.id)},At=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=Y.filter(lt=>lt.folderId===Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return Be.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Be.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:Be.map($e)})]}),We.map(lt=>At(lt,re+1,Ne))]},Q.id)},bt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>o?.(Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(xf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:ae,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:Se=>he(Q.id,{enabled:Se.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:Se=>he(Q.id,{key:Se.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:Se=>he(Q.id,{value:Se.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>we(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),bt.map(Q=>ft(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(xf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map($e),bt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function Uo(){return new Date().toISOString()}const xM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),o=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=Uo(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!o)return;const w=Uo();e(A=>({...A,environments:A.environments.map(C=>C.id===o.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!o)return;const C=Uo();e(E=>({...E,environments:E.environments.map(D=>D.id===o.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),o&&p.jsx("button",{type:"button","aria-label":`Delete environment ${o.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,o.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),o&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:o.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[o.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),o.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function nu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function vM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",o=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,o,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=nu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function wM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),o=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:o,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const o=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=kd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` -`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${o}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:o,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${o}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":o,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":o}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${o}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${o}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function op(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function AM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=AM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,o)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${o}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const kM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:o,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:o||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>vM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>wM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},ae=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],we=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:ae,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=nu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[op(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:nu(ne)?"text-red-600":j,children:op(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:nu(B)?"text-red-600":j,children:op(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[we,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ot(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?ot(r.value):""}function CM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function ap(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=CM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const o=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return o("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){o("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return o("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){o("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(o("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const o=ot(r.key).trim();return o?[{id:An("variable"),key:o,value:ot(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function NM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(o=>t.includes(o));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function TM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(ot).join(` +`):ot(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,o)=>{const c=ot(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${o}]`,f=TM(s.script,`${u}.script`,n).trim();if(!f)return;const h=NM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function jM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function EM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(o=>{const c=o.indexOf("=");return{key:S1(c>=0?o.slice(0,c):o),value:S1(c>=0?o.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function OM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function MM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=ot(r.key).trim();s&&(n=n.replace(new RegExp(`:${MM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function RM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=OM(t.query),n=ot(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=ot(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(ot).join("."):ot(t.host),o=ot(t.port),c=Array.isArray(t.path)?t.path.map(ot).join("/"):ot(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${o?`:${o}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function DM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function _M(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function LM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function qM(t,e,n,r){const s=_M(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const o=ot(t.mode);if(o==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?ot(c.language):"";return{body:ot(t.raw),contentType:s||LM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(o==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:ot(u.key),value:ot(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(o==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=ot(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:ot(c.query),variables:u},contentType:s||"application/json"}}if(o==="formdata"){const c=Xr(t.formdata).map(f=>{const h=ot(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(ot).filter(Boolean).join(", "):ot(f.src);return{key:ot(f.key),value:h==="text"?ot(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(o==="file"){const c=mn(t.file)?ot(t.file.src):ot(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${o}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function BM(t,e,n,r,s,o,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=ot(f.method).trim().toUpperCase()||"GET",g=RM(f.url),b=DM(f.header),v=qM(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:ap(f.auth,{type:"inherit"},`${c}.auth`,u)},A=EM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:o,updatedAt:o}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=ot(e.name)||"Untitled",o=w1(e.event,`${r}.event`,t.warnings),c=jM(t.inheritedScripts,o);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:ap(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=BM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function $M(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=ot(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=ot(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),o=An("collection"),c={id:o,name:e,auth:ap(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:o,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function IM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=ot(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function HM(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:$M(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:IM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function zM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function UM(t,e){const n=zM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function VM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const FM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,o]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=HM(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?UM(M,G.result):VM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?o({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?o({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):o({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(ao,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function PM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e.folderId);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function YM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const KM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const ae=await gM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(we=>({...we,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(we=>({...we,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(ae.workspace),Y(he=>Object.fromEntries(C.map(we=>{const T=he[we.id]||{status:"pending"};return[we.id,T.status==="pending"&&ae.stopped?{status:"skipped"}:T]}))),M(ae),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(co,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(co,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,ae)=>{const he=G[J.id]||{status:"pending"},we=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=we?.status!==void 0&&we.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:ae+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:PM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(ao,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:YM(he)}),we?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",we.status]}),we?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(Nd,{className:"mr-1 inline h-3.5 w-3.5"}),we.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Vo(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function GM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return po(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function XM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:o="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=GM(t),Y=Sn(e),B=nl(),K=o===!1?{}:j1(o),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[ae,he]=I.useState(Y),[we,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[$e,ft]=I.useState({}),[At,bt]=I.useState(),[Ge,Q]=I.useState(B),[re,Se]=I.useState(B.collections[0]?.id),[Ne,Be]=I.useState(""),We=I.useRef(B.collections[0]?.id),lt=I.useRef(void 0),[ti,Tn]=I.useState(o===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(o===!1)return;let Me=!1;return hy(o).then(Ze=>{Me||(Q(Ze),Se(Ze.collections[0]?.id),Be(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[o]);const x=my(o,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>hf(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,ae),[ce,ae]),V=I.useMemo(()=>XM(ce,ae)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,ae,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),ve=I.useCallback(Me=>{Se(Me),Be("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},le=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),o!==!1&&Vo(o,{requestTab:Me}),C?.(Me)},Te=Me=>{qe(Me),o!==!1&&Vo(o,{scriptTab:Me}),E?.(Me)},je=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>pf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,lt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>ay(Ze,{...Me,collectionId:We.current,folderId:lt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Se(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Be(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),o!==!1&&Vo(o,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{Se(Me),Be(Ze||""),bt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{ft({entryId:Me,runId:Ze}),Je("history")},Fo=()=>ni(Me=>{const Ze=!Me;return o!==!1&&Vo(o,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Fo,children:ht?p.jsx(Ed,{className:"h-4 w-4"}):p.jsx(jd,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(bf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(FM,{onWorkspaceChange:Q,onSelectedCollectionChange:ve,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(xM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(bM,{request:ce,scripts:ae,onLoadRequest:Dt,onSelectedCollectionChange:ve,onSelectedFolderChange:Be,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),o!==!1&&Vo(o,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(kM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:$e.entryId,initialRunId:$e.runId,theme:kt},`${$e.runId||""}:${$e.entryId||""}`):He==="runner"&&At?p.jsx(KM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:we,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:je,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:le,onRequestTabChange:Ae,onScriptTabChange:Te,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function iu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function JM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,o]of Object.entries(t.paths))for(const c of In.getHttpMethods(o)){if(Wc(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function QM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${iu(n.padding.vertical)||"0"} ${iu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:iu(n.maxHeight)||"32px",maxWidth:iu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const WM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const o=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=ho(o),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:o,preferences:c})),ae=I.useRef(null),he=I.useRef(null),we=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===o?q.preferences:ho(o),Je=n&&He.theme||e,$e=Je==="high-contrast"?"dark":Je,ft=He.expand,At=He.expandedTags??["default"],bt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...JM($e,Ge),...r}),[$e,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return P3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const le=R1(t,window.location.hash);if(le){g(le);return}const Ae=window.location.hash.replace(/^#/,"");g(Te=>Te&&Ae&&Wc(Te.path,Te.method)===Ae?Te:null)},de=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const le=ae.current,Ae=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Te=je=>{if(je.key==="Escape"){je.preventDefault(),M(!1);return}if(je.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];je.shiftKey&&document.activeElement===ze?(je.preventDefault(),Ve.focus()):!je.shiftKey&&document.activeElement===Ve&&(je.preventDefault(),ze.focus())};return document.addEventListener("keydown",Te),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Te),de?.focus()}},[L]);const re=()=>{J({key:o,preferences:ho(o)})},Se=F=>{J(de=>{const le=de.key===o?de.preferences:ho(o);return{key:o,preferences:{...le,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>we.current?.scrollTo({top:0,behavior:"auto"})),Be=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wc(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},lt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!bt;Ba(o,"sidebarCollapsed",F),Se({sidebarCollapsed:F})},ht=nf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ft===void 0?ht:nf(ft),Vn=F=>{Ba(o,"expand",F),re()},qn=F=>{n&&(Ba(o,"theme",F),re())},kt=F=>{Ba(o,"expandedTags",F),Se({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=B3($e,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=$e==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=$e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),ve=p.jsx(pk,{spec:t,onEndpointSelect:Be,theme:$e,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.logo?p.jsx(QM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(iM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${bt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":bt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!bt&&ve}),p.jsxs("main",{ref:we,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(O3,{spec:t,path:h.path,method:h.method,theme:$e,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:lt}):p.jsx(_3,{spec:t,onEndpointSelect:Be,theme:$e}),p.jsx(q3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:$e,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:ae,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${$e==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:ve})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${$e==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(tM,{open:B&&T,theme:$e,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:Be,messages:X}),p.jsx(X3,{spec:t,theme:$e,messages:X,onEndpointSelect:Be,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>lt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Z3,{open:G,theme:$e,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:ft,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function ZM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function eR(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function tR(t,e){const n=e.load||ZM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),o={},c=new Map;async function u(g){if(g===r)return s;if(o[g])return o[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return o[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=eR(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(o).length&&(s[dp]=o),s}async function nR(t,e){return tR(t,e)}const ru="1",su=new WeakMap;function iR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=iR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},o=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!o.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function rR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function sR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=su.get(t);n&&n.unmount();const r=$A.createRoot(t);return su.set(t,r),r.render(e),()=>{su.get(t)===r&&su.delete(t),r.unmount()}}function $1(t,e,n){return sR(n),B1(t,p.jsx(WM,{spec:fp(e,n),theme:rR(n),options:n}))}function I1(t,e){const n={contractVersion:ru,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:ru,...e.options||{}},r=e.baseUri?await nR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:ru}),As.FLEXDOC_CONTRACT_VERSION=ru,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/python/src/prauga_flexdoc/_assets/flexdoc.standalone.js b/adapters/python/src/prauga_flexdoc/_assets/flexdoc.standalone.js index 3efc5433..bf78a4d9 100644 --- a/adapters/python/src/prauga_flexdoc/_assets/flexdoc.standalone.js +++ b/adapters/python/src/prauga_flexdoc/_assets/flexdoc.standalone.js @@ -1,86 +1,86 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(q,J){var oe=q.length;q.push(J);e:for(;0>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1>>1,we=q[he];if(0>>1;hes(me,ae))nes(Ce,me)?(q[he]=Ce,q[ne]=ae,he=ne):(q[he]=me,q[z]=ae,he=z);else if(nes(Ce,ae))q[he]=Ce,q[ne]=ae,he=ne;else break e}}return J}function s(q,J){var ae=q.sortIndex-J.sortIndex;return ae!==0?ae:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var we=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof we=="function"){b.callback=we,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=ae,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=ae,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,ae-he))):(q.sortIndex=we,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var ae=v;v=J;try{return q.apply(this,arguments)}finally{v=ae}}}})(vd)),vd}var Ng;function RA(){return Ng||(Ng=1,xd.exports=MA()),xd.exports}var wd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function($e){return $e})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ad.exports=_A(),Ad.exports}var Mg;function qA(){if(Mg)return oo;Mg=1;var t=RA(),e=Sd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1we||(i.current=he[we],he[we]=null,we--)}function me(i,l){we++,he[we]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function $e(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,a=Q2(l,i.type);l!==a&&(me(Ce,i),me(ne,a))}function ft(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oa._currentValue=ae)}var At,bt;function Ge(i){if(At===void 0)try{throw Error()}catch(a){var l=a.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",bt=-1)":-1m||$[d]!==te[m]){var fe=` -`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ge(a):""}function Se(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",a=null;do l+=Se(i,a),a=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var $e=Object.prototype.hasOwnProperty,We=t.unstable_scheduleCallback,vt=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ft=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,kt=t.unstable_NormalPriority,x=t.unstable_LowPriority,U=t.unstable_IdlePriority,pe=t.log,ue=t.unstable_setDisableYieldValue,X=null,k=null;function V(i){if(typeof pe=="function"&&ue(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var W=Math.clz32?Math.clz32:de,we=Math.log,F=Math.LN2;function de(i){return i>>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(ve(i)/F|0)|0}var le=256,Ae=262144,Te=4194304;function je(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,a){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=je(d):(S&=N,S!==0?m=je(S):a||(a=N&~i,a!==0&&(m=je(a))))):(N=d&~y,N!==0?m=je(N):S!==0?m=je(S):a||(a=d&~i,a!==0&&(m=je(a)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,a=l&-l,y>=a||y===32&&(a&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Te;return Te<<=1,(Te&62914560)===0&&(Te=4194304),i}function Fn(i){for(var l=[],a=0;31>a;a++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Fo(i,l,a,d,m,y){var S=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(a=S&~a;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var oR=/[\n"\\]/g;function vi(i){return i.replace(oR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,a,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):a!=null?gp(i,S,On(a)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,a,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}a=a!=null?""+On(a):"",l=l!=null?""+On(l):a,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,a){l==="number"&&ou(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Tl(i,l,a,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Go={};Object.defineProperty(Go,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Go,Go),window.removeEventListener("test",Go,Go)}catch{wp=!1}var es=null,Sp=null,cu=null;function Q1(){if(cu)return cu;var i,l=Sp,a=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Qo),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return LR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function BR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function $R(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),cu=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:a,offset:l-i};i=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=pw(a)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=ou(i.document);l instanceof i.HTMLIFrameElement;){try{var a=typeof l.contentWindow.location.href=="string"}catch{a=!1}if(a)i=l.contentWindow;else break;l=ou(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var YR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,ta=null,Rp=!1;function bw(i,l,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Rp||Rl==null||Rl!==ou(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),ta&&ea(ta,d)||(ta=d,d=nd(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|a<it?(dt=Ie,Ie=null):dt=Ie.sibling;var vt=ie(P,Ie,Z[it],ye);if(vt===null){Ie===null&&(Ie=dt);break}i&&Ie&&vt.alternate===null&&l(P,Ie),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt,Ie=dt}if(it===Z.length)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;itit?(dt=Ie,Ie=null):dt=Ie.sibling;var Ss=ie(P,Ie,vt.value,ye);if(Ss===null){Ie===null&&(Ie=dt);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),xt===null?Fe=Ss:xt.sibling=Ss,xt=Ss,Ie=dt}if(vt.done)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;!vt.done;it++,vt=Z.next())vt=xe(P,vt.value,ye),vt!==null&&(H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return pt&&gr(P,it),Fe}for(Ie=d(Ie);!vt.done;it++,vt=Z.next())vt=oe(Ie,P,it,vt.value,ye),vt!==null&&(i&&vt.alternate!==null&&Ie.delete(vt.key===null?it:vt.key),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return i&&Ie.forEach(function(fD){return l(P,fD)}),pt&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){a(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){a(P,H.sibling),ye=m(H,Z.props),oa(ye,Z),ye.return=P,P=ye;break e}a(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=xu(Z.type,Z.key,Z.props,null,P.mode,ye),oa(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){a(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{a(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,Nu(Z),ye);if(Z.$$typeof===j)return Et(P,H,Su(P,Z),ye);Tu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(a(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(a(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):a(P,H)}return function(P,H,Z,ye){try{la=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===ku)throw Ie;var xt=li(29,Ie,null,P.mode);return xt.lanes=ye,xt.return=P,xt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function os(i,l,a){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=bu(i),Cw(i,null,a),l}return yu(i,d,l,a),bu(i)}function aa(i,l,a){if(l=l.updateQueue,l!==null&&(l=l.shared,(a&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}function Zp(i,l){var a=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var m=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var S={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,a=a.next}while(a!==null);y===null?m=y=l:y=y.next=l}else m=y=l;a={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=l:i.next=l,a.lastBaseUpdate=l}var em=!1;function ca(){if(em){var i=zl;if(i!==null)throw i}}function ua(i,l,a,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,oe=ie!==N.lane;if(oe?(ut&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=a;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=m.callbacks,oe===null?m.callbacks=[ie]:oe.push(ie))}else oe={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=oe,$=xe):fe=fe.next=oe,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;oe=N,N=oe.next,oe.next=null,m.lastBaseUpdate=oe,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,a);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=t4($,d);ha(i,l,fe,di(i))}else ha(i,l,d,di(i))}catch(xe){ha(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function o4(){}function ym(i,l,a,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,ae,a===null?o4:function(){return AS(i),a(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ae},next:null};var a={};return l.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ha(i,l.next.queue,{},di())}function bm(){return yn(Oa)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function a4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var a=di();i=ls(a);var d=os(l,i,a);d!==null&&(Qn(d,l,a),aa(d,l,a)),l={cache:Kp()},i.payload=l;return}l=l.return}}function c4(i,l,a){var d=di();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bu(i)?TS(l,a):(a=qp(i,l,a,d),a!==null&&(Qn(a,i,d),jS(a,l,d)))}function NS(i,l,a){var d=di();ha(i,l,a,d)}function ha(i,l,a,d){var m={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,a);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return yu(i,l,m,0),Mt===null&&gu(),!1}catch{}if(a=qp(i,l,m,d),a!==null)return Qn(a,i,d),jS(a,l,d),!0}return!1}function xm(i,l,a,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Bu(i)){if(l)throw Error(r(479))}else l=qp(i,a,d,2),l!==null&&Qn(l,i,2)}function Bu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=Ou=!0;var a=i.pending;a===null?l.next=l:(l.next=a.next,a.next=l),i.pending=l}function jS(i,l,a){if((a&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}var pa={readContext:yn,use:Du,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};pa.useEffectEvent=zt;var ES={readContext:yn,use:Du,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,a){a=a!=null?a.concat([i]):null,Lu(4194308,4,gS.bind(null,l,i),a)},useLayoutEffect:function(i,l){return Lu(4194308,4,i,l)},useInsertionEffect:function(i,l){Lu(4,2,i,l)},useMemo:function(i,l){var a=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return a.memoizedState=[d,l],d},useReducer:function(i,l,a){var d=$n();if(a!==void 0){var m=a(l);if(Js){V(!0);try{a(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=c4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,a=NS.bind(null,nt,l);return l.dispatch=a,[i.memoizedState,a]},useDebugValue:mm,useDeferredValue:function(i,l){var a=$n();return gm(a,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,a){var d=nt,m=$n();if(pt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=l(),Mt===null)throw Error(r(349));(ut&127)!==0||Jw(d,l,a)}m.memoizedState=a;var y={value:a,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,a,l),null),a},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(pt){var a=Zi,d=Wi;a=(d&~(1<<32-W(d)-1)).toString(32)+a,l="_"+l+"R_"+a,a=Mu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,a),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,a=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,a)),i||is(l,!0)}else i=id(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(a=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),a!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else a=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return l.flags&256?(ai(l),l):(ai(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(ai(l),l):(ai(l),null)}return ai(l),(l.flags&128)!==0?(l.lanes=a,l):(a=d!==null,i=i!==null&&i.memoizedState!==null,a&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),a!==i&&a&&(l.child.flags|=8192),Uu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)ga(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Eu(i),y!==null){for(l.flags|=128,ga(d,!1),i=y.updateQueue,l.updateQueue=i,Uu(l,i),l.subtreeFlags=0,i=a,a=l.child;a!==null;)Nw(a,i),a=a.sibling;return me(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Ku&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304)}else{if(!m)if(i=Eu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Uu(l,i),ga(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Ku&&a!==536870912&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,a=Kt.current,me(Kt,m?a&1|2:a&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return ai(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(a&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),a=l.updateQueue,a!==null&&Uu(l,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==a&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),l.memoizedState.cache!==a&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function p4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ft(l),null;case 31:if(l.memoizedState!==null){if(ai(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(ai(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return ai(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:ft(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&ai(l);break;case 13:ai(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:ai(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function ya(i,l){try{var a=l.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var m=d.next;a=m;do{if((a.tag&i)===i){d=void 0;var y=a.create,S=a.inst;d=y(),S.destroy=d}a=a.next}while(a!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,a){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=a,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var a=i.stateNode;try{Fw(l,a)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,a){a.props=Qs(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(d){Nt(i,l,d)}}function ba(i,l){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof a=="function"?i.refCleanup=a(d):a.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var a=i.ref,d=i.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(m){Nt(i,l,m)}else a.current=null}function n2(i){var l=i.type,a=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,a){try{var d=i.stateNode;q4(d,i.type,a,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,l):(l=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,l.appendChild(i),a=a._reactRootContainer,a!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,a),i=i.sibling;i!==null;)qm(i,l,a),i=i.sibling}function Vu(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?a.insertBefore(i,l):a.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vu(i,l,a),i=i.sibling;i!==null;)Vu(i,l,a),i=i.sibling}function r2(i){var l=i.stateNode,a=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,a),l[_t]=i,l[Yt]=a}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,an=null;function m4(i,l){if(i=i.containerInfo,rg=ud,i=yw(i),Op(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var oe;xe!==a||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(oe=xe.firstChild)!==null;)ie=xe,xe=oe;for(;;){if(xe===i)break t;if(ie===a&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(oe=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=oe}a=N===-1||$===-1?null:{start:N,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(sg={focusedElem:i,selectionRange:a},ud=!1,an=l;an!==null;)if(l=an,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,an=i;else for(;an!==null;){switch(l=an,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a title"))),xn(y,d,a),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(a.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(oe.rangeCount!==1||oe.anchorNode!==P.node||oe.anchorOffset!==P.offset||oe.focusNode!==H.node||oe.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),oe.removeAllRanges(),Ye>Et?(oe.addRange(Z),oe.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),oe.addRange(Z))}}}}for(xe=[],oe=N;oe=oe.parentNode;)oe.nodeType===1&&xe.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Na?32:a,q.T=null,a=Fm,Fm=null;var y=ps,S=jr;if(ln=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,a),wt=N,ka(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,a){l=Si(a,l),l=Am(i.stateNode,l,2),i=os(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,a){if(i.tag===3)q2(i,i,a);else for(;l!==null;){if(l.tag===3){q2(l,i,a);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(a,i),a=BS(2),d=os(l,a,2),d!==null&&($S(a,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,a){var d=i.pingCache;if(d===null){d=i.pingCache=new b4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(a)||(Hm=!0,m.add(a),i=A4.bind(null,i,l,a),l.then(i,i))}function A4(i,l,a){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ut&a)===a&&(Ut===4||Ut===3&&(ut&62914560)===ut&&300>ht()-Yu?(wt&2)===0&&Zl(i,0):zm|=a,Ql===ut&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function k4(i){var l=i.memoizedState,a=0;l!==null&&(a=l.retryLane),B2(i,a)}function C4(i,l){var a=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(a=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,a)}function N4(i,l){return We(i,l)}var Zu=null,to=null,Xm=!1,ed=!1,Jm=!1,gs=0;function tr(i){i!==to&&i.next===null&&(to===null?Zu=to=i:to=to.next=i),ed=!0,Xm||(Xm=!0,j4())}function ka(i,l){if(!Jm&&ed){Jm=!0;do for(var a=!1,d=Zu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,z2(d,y))}else y=ut,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(a=!0,z2(d,y));d=d.next}while(a);Jm=!1}}function T4(){$2()}function $2(){ed=Xm=!1;var i=0;gs!==0&&$4()&&(i=gs);for(var l=ht(),a=null,d=Zu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,a===null?Zu=m:a.next=m,m===null&&(to=a)):(a=d,(i!==0||(y&3)!==0)&&(ed=!0)),d=m}ln!==0&&ln!==5||ka(i),gs!==0&&(gs=0)}function I2(i,l){for(var a=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function oA(i,l,a){var d=no;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof a=="string"&&(m+='[crossorigin="'+a+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:a,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function K4(i){Er.D(i),oA("dns-prefetch",i,null)}function G4(i,l){Er.C(i,l),oA("preconnect",i,l)}function X4(i,l,a){Er.L(i,l,a);var d=no;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&a&&a.imageSrcSet?(m+='[imagesrcset="'+vi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(m+='[imagesizes="'+vi(a.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=io(i);break;case"script":y=ro(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&a&&a.imageSrcSet?void 0:i,as:l},a),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(ja(y))||l==="script"&&d.querySelector(Ea(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function J4(i,l){Er.m(i,l);var a=no;if(a&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ro(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),a.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ea(y)))return}d=a.createElement("link"),xn(d,"link",i),Xt(d),a.head.appendChild(d)}}}function Q4(i,l,a){Er.S(i,l,a);var d=no;if(d&&i){var m=fr(d).hoistableStyles,y=io(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(ja(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},a),(a=ji.get(y))&&fg(i,a);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,sd(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function W4(i,l){Er.X(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Z4(i,l){Er.M(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function aA(i,l,a,d){var m=(m=Re.current)?rd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(l=io(a.href),a=fr(m).hoistableStyles,d=a.get(l),d||(d={type:"style",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=io(a.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(ja(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ji.set(i,a),y||eD(m,i,a,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=a.async,a=a.src,typeof a=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ro(a),a=fr(m).hoistableScripts,d=a.get(l),d||(d={type:"script",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function io(i){return'href="'+vi(i)+'"'}function ja(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function eD(i,l,a,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",a),Xt(l),i.head.appendChild(l))}function ro(i){return'[src="'+vi(i)+'"]'}function Ea(i){return"script[async]"+i}function uA(i,l,a){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(a.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),sd(d,a.precedence,i),l.instance=d;case"stylesheet":m=io(a.href);var y=i.querySelector(ja(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(a),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,sd(y,a.precedence,i),l.instance=y;case"script":return y=ro(a.src),(m=i.querySelector(Ea(y)))?(l.instance=m,Xt(m),m):(d=a,(m=ji.get(y))&&(d=b({},a),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,sd(d,a.precedence,i));return l.instance}function sd(i,l,a){for(var d=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function tD(i,l,a){if(a===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function nD(i,l,a,d){if(a.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var m=io(d.href),y=l.querySelector(ja(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=od.bind(i),l.then(i,i)),a.state.loading|=4,a.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),a.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,l),(l=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=od.bind(i),l.addEventListener("load",a),l.addEventListener("error",a))}}var pg=0;function iD(i,l){return i.stylesheets&&i.count===0&&cd(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function od(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ad=null;function cd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ad=new Map,l.forEach(rD,i),ad=null,od.call(i))}function rD(i,l){if(!(l.state.loading&4)){var a=ad.get(i);if(a)var d=a.get(null);else{a=new Map,ad.set(i,a);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),bd.exports=qA(),bd.exports}var $A=BA(),I=Sd();const kd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!o&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(o)?o:[o]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},o)=>I.createElement(VA,{ref:o,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _a=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Cd=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const ao=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Nd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Td=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const La=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const jd=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const Ed=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const co=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Od=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Md=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},qa={},Or={},Pg;function uo(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` -`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` -`,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` -`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentb&&(h=" ... ",o=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(o,c).replace(/\t/g,"→")+g,pos:u-o+h.length}}function n(s,o){return t.repeat(" ",o-s.length)+s}function r(s,o){if(o=Object.create(o||null),!s.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+o.linesAfter,f.length).toString().length,w=o.maxLength-(o.indent+v+3);for(let C=1;C<=o.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",o.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` +`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",o.indent)+n((s.line+1).toString(),v)+" | "+A.str+` +`,b+=t.repeat("-",o.indent+v+3+A.pos)+`^ +`;for(let C=1;C<=o.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",o.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Dd=r,Dd}var _d,Gg;function Mn(){if(Gg)return _d;Gg=1;const t=fo(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(o){const c={};return o!==null&&Object.keys(o).forEach(function(u){o[u].forEach(function(f){c[String(f)]=u})}),c}function s(o,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+o+'" YAML type.')}),this.options=c,this.tag=o,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return _d=s,_d}var Ld,Xg;function Jg(){if(Xg)return Ld;Xg=1;const t=fo(),e=Mn();function n(o,c){const u=[];return o[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(o.multi[u.kind].push(u),o.multi.fallback.push(u)):o[u.kind][u.tag]=o.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function o(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ud}var Vd,d0;function f0(){if(d0)return Vd;d0=1;const t=uo(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function o(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Vd=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:o,predicate:f,represent:u,defaultStyle:"lowercase"}),Vd}var Fd,h0;function p0(){return h0||(h0=1,Fd=r0().extend({implicit:[l0(),a0(),u0(),f0()]})),Fd}var Pd,m0;function g0(){return m0||(m0=1,Pd=p0()),Pd}var Yd,y0;function b0(){if(y0)return Yd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function o(c){return c.toISOString()}return Yd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:o}),Yd}var Kd,x0;function v0(){if(x0)return Kd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Kd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Kd}var Gd,w0;function S0(){if(w0)return Gd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function o(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Gd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:s}),Gd}var Xd,A0;function k0(){if(A0)return Xd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(o){if(o===null)return!0;const c={},u=o;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function ae(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function we(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function bt(x,U,pe){let ue,X,k,V,W,ve;const F=x.kind,de=x.result;let le=x.input.charCodeAt(x.position);if(R(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;le!==0;){if(le===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(le===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&ft(x)||pe&&_(le))break;if(O(le))if(V=x.line,W=x.lineStart,ve=x.lineIndent,$e(x,!1,-1),x.lineIndent>=U){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=ve;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))$e(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const ve=x.anchor;let F,de,le,Ae;const Te=Object.create(null);let je,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&ae(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if($e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=ve,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=je=ze=null,de=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=le=!0,x.position++,$e(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ht(x,U,o,!1,!0),Le=x.tag,je=x.result,$e(x,!0,U),Ve=x.input.charCodeAt(x.position),(le||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),$e(x,!0,U),ht(x,U,o,!1,!0),ze=x.result),Ae?He(x,W,Te,Le,je,ze,ue,X,k):de?W.push(He(x,null,Te,Le,je,ze,ue,X,k)):W.push(je),$e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function Se(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,ve=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` -`,de=we&&(k[k.length-2]===` +`,X?1+W:W),X=!0,k=!0,W=0;const le=x.position;for(;!O(de)&&de!==0;)de=x.input.charCodeAt(++x.position);Ce(x,le,x.position,!1)}return!0}function Ne(x,U){const pe=x.tag,ue=x.anchor,X=[];let k=!1;if(x.firstTabInLine!==-1)return!1;x.anchor!==null&&ae(x,x.anchor,X);let V=x.input.charCodeAt(x.position);for(;V!==0&&(x.firstTabInLine!==-1&&(x.position=x.firstTabInLine,q(x,"tab characters must not be used in indentation")),V===45);){const W=x.input.charCodeAt(x.position+1);if(!R(W))break;if(k=!0,x.position++,$e(x,!0,-1)&&x.lineIndent<=U){X.push(null),V=x.input.charCodeAt(x.position);continue}const ve=x.line;if(ht(x,U,u,!1,!0),X.push(x.result),$e(x,!0,-1),V=x.input.charCodeAt(x.position),(x.line===ve||x.lineIndent>U)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(je&&(X=x.line,k=x.lineStart,V=x.position),ht(x,U,f,!0,ue)&&(je?Ae=x.result:Te=x.result),je||(He(x,F,de,le,Ae,Te,X,k,V),le=Ae=Te=null),$e(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const je=k=V=f===pe||u===pe;if(ue&&$e(x,!0,-1)&&(ve=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&le.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&ae(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&($e(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if($e(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,$e(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),$e(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ft(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,$e(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==o||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==o&&k!==f&&k!==u}function He(k,V,W){const ve=qe(k),F=ve&&!Ce(k);return(W?ve:ve&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==o&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function $e(k){return!Ce(k)&&k!==j}function ft(k,V){const W=k.charCodeAt(V);let ve;return W>=55296&&W<=56319&&V+1=56320&&ve<=57343)?(W-55296)*1024+ve-56320+65536:W}function At(k){return/^\n* /.test(k)}const bt=1,Ge=2,Q=3,re=4,Se=5;function Ne(k,V,W,ve,F,de,le,Ae){let Te,je=0,Le=null,ze=!1,Ve=!1;const Dt=ve!==-1;let Fn=-1,jn=Je(ft(k,0))&&$e(ft(k,k.length-1));if(V||le)for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}else{for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),je===u)ze=!0,Dt&&(Ve=Ve||Te-Fn-1>ve&&k[Fn+1]!==" ",Fn=Te);else if(!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}Ve=Ve||Dt&&Te-Fn-1>ve&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!F(k)?bt:de===we?Se:Ge:W>9&&At(k)?Se:le?de===we?Se:Ge:Ve?re:Q}function Be(k,V,W,ve,F){k.dump=(function(){if(V.length===0)return k.quotingType===we?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===we?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=ve||k.flowLevel>-1&&W>=k.flowLevel;function Te(je){return ne(k,je)}switch(Ne(V,Ae,k.indent,le,Te,k.quotingType,k.forceQuotes&&!ve,F)){case bt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+lt(z(V,de));case re:return">"+We(V,k.indent)+lt(z(ti(V,le),de));case Se:return'"'+ht(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",ve=k[k.length-1]===` +`,de=ve&&(k[k.length-2]===` `||k===` -`)?"+":we?"":"-";return W+de+` -`}function vt(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`)?"+":ve?"":"-";return W+de+` +`}function lt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let ve=(function(){let Ae=k.indexOf(` `);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` -`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` -`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` -`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` -`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` -`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ -`)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); -const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` -`)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` -`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`||k[0]===" ",de,le;for(;le=W.exec(k);){const Ae=le[1],Te=le[2];de=Te[0]===" ",ve+=Ae+(!F&&!de&&Te!==""?` +`:"")+Tn(Te,V),F=de}return ve}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let ve,F=0,de,le=0,Ae=0,Te="";for(;ve=W.exec(k);)Ae=ve.index,Ae-F>V&&(de=le>F?le:Ae,Te+=` +`+k.slice(F,de),F=de+1),le=Ae;return Te+=` +`,k.length-F>V&&le>F?Te+=k.slice(F,le)+` +`+k.slice(le+1):Te+=k.slice(F),Te.slice(1)}function ht(k){let V="",W=0;for(let ve=0;ve=65536?ve+=2:ve++){W=ft(k,ve);const F=ce[W];!F&&Re(W)?(V+=k[ve],W>=65536&&(V+=k[ve+1])):V+=F||ae(W)}return V}function ni(k,V,W){let ve="";const F=k.tag;for(let de=0,le=W.length;de"u"&&U(k,V,null,!1,!1))&&(ve!==""&&(ve+=","+(k.condenseFlow?"":" ")),ve+=k.dump)}k.tag=F,k.dump="["+ve+"]"}function Vn(k,V,W,ve){let F="";const de=k.tag;for(let le=0,Ae=W.length;le"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!ve||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let ve="";const F=k.tag,de=Object.keys(W);for(let le=0,Ae=de.length;le1024&&(Te+="? "),Te+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Te+=k.dump,ve+=Te))}k.tag=F,k.dump="{"+ve+"}"}function kt(k,V,W,ve){let F="";const de=k.tag,le=Object.keys(W);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Te=le.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?je+="?":je+="? "),je+=k.dump,Ve&&(je+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?je+=":":je+=": ",je+=k.dump,F+=je)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const ve=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=ve.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Te}return!0}}return!1}function U(k,V,W,ve,F,de,le){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Te=ve;ve&&(ve=k.flowLevel<0||k.flowLevel>V);const je=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(je&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(je&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")ve&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")ve&&k.dump.length!==0?(k.noArrayIndent&&!le&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&Be(k,k.dump,V,de,Te);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],ve=[];ue(k,W,ve);const F=ve.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const o of r){if(s===null||typeof s!="object"||!(o in s))throw new Error(`Reference not found: ${n}`);s=s[o]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const o=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return o[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:o,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),o?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],tf={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(tf),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function nf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...tf[t]]:Cs.filter(n=>t.some(r=>r===n||tf[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function ho(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(o=>typeof o=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function Ba(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const o={...ho(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete o[e]:o[e]=c,o.expand===void 0&&o.sidebarCollapsed===void 0&&o.theme===void 0&&o.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(o))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],o=e[r]??s?.default;if(o===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(o))throw new Error(`Invalid value for server variable ${r}: ${o}`);return o})}function rf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const o=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of o)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return rf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=rf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const o=r.requestBody,c=o?Object.keys(o.content||{})[0]:void 0;if(c){s.contentType=c;const u=o.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function sf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=sf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,o])=>`${s}=${cn(o)}`).join(","):r.flatMap(([s,o])=>[s,cn(o)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=sf(e),o=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(o);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[o(f),o(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=o(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=sf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([o,c])=>[`${t.name}[${o}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(o=>[t.name,cn(o)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const o=Object.entries(s);return r?o.map(([c,u])=>[c,cn(u)]):[[t.name,o.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,o){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,o))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=o[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=rf(t,e,n),o=s.servers[0],c=r.serverUrl||(o?wk(o,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const o=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)o.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&o.push(` --data-raw ${un(t.body)}`),o.join(` \\ +`)}if(e==="javascript"){const o={method:t.method};return n.length&&(o.headers=t.headers),t.body&&(o.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(o,null,2)}); +const data = await response.json();`}if(e==="python"){const o=["import requests","",`url = ${un(t.url)}`];return n.length&&o.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&o.push(`body = ${un(t.body)}`),o.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),o.join(` +`)}if(e==="go"){const o=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${o})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` +`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[o,c]of n)r.push(` .header(${un(o)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var lf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,o=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=ae.value.length,ae=ae.next){var we=ae.value;if(j.length>O.length)return;if(!(we instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=ae.value.length;Re>=ne;)ae=ae.next,ne+=ae.value.length;if(ne-=ae.value.length,he=ne,ae.value instanceof f)continue;for(var Ce=ae;Ce!==j.tail&&(neM.reach&&(M.reach=$e);var ft=ae.prev;He&&(ft=v(j,ft,He),he+=He.length),w(j,ft,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(ae=v(j,ft,At),Je&&v(j,ae,Je),T>1){var bt={cause:G+","+B,reach:$e};g(O,j,R,ae.prev,he,bt),M&&bt.reach>M.reach&&(M.reach=bt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+o+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(o),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:o=!1})=>{const[c,u]=kd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${o?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:o=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(o.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(o);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:o})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:o},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:o})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:o})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function $a(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),o=Object.keys(r);return s.length===o.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function of(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const o=e(),c=of(o,r),u={key:r,value:String(s),enabled:!0};c>=0?o[c]=u:o.push(u)};return{get(r){const s=of(e(),r);return s>=0?e()[s].value:void 0},has(r){return of(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=$a(t.variables||{}),r=$a(t.collectionVariables||{}),s=$a(t.externalVariables||{}),o=$a(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(o,R)?n[R]=o[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return o[R]},has(R){return Object.prototype.hasOwnProperty.call(o,R)},set(R,_){const L=String(_);o[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete o[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(o,M)?o[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` -`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!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:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,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}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{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 n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.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 fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(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(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(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}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(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,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}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 n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` -`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;se.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",o=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${o}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const o=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>o.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:o}}function cf(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function Ia(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&Ia(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&Ia(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&Ia(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&Ia(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const o=Y0(n);if(o.length>0)throw new Error(`This request requires API host execution (${o.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=cf(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,o])=>({key:s,value:o})),body:t.body,contentType:cf(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:cf(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,o])=>({key:s,value:o,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function po(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const o=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return o&&!("$ref"in o)?o:void 0}function lC(t,e,n,r){const o=rC(t,e,n)?.security??t.security??[];if(!o.length)return;const c=o.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=o.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(o.find(f=>Object.keys(f).length===0)??o[0])}function oC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,o=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:o?.authorizationUrl,tokenUrl:o?.tokenUrl,scopes:n.length?n:Object.keys(o?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function aC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let o=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return o;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return o;if(!h)return{...o,auth:{type:"inherit"}};const g=oC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?o=X0(o,"Authorization"):g.type==="apiKey"&&g.in==="header"?o=X0(o,g.key):g.type==="apiKey"&&g.in==="query"&&(o=aC(o,g.key)),{...o,auth:g}):o}function uC(t,e,n,r,s){const o=B0(t,e,n,r);return{request:cC(t,e,n,r,o),serverUrl:r.serverUrl||s}}function Ha(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const uf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function df(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>df(e.key)?{...e,value:uf}:e)}function fC(t){return t?.map(e=>df(e[0])?[e[0],uf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const o=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return df(g)?`${h}=${encodeURIComponent(uf)}`:u}).join("&");return`${o}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Ha(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",o={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete o.responseBody,delete o.responseBodyTruncated,delete o.requestBodyTruncated),o});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Ha(n.auth)})),folders:t.folders.map(n=>({...n,auth:Ha(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Ha(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function mo(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function za(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function Ua(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!Ua(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Va(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function ff(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(ff(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Va(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(ff(t),JSON.stringify(wC(e))):sessionStorage.removeItem(ff(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(Ua))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(Ua))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(Ua))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Va(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Va(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Va(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const o=r.get(s.parentFolderId);(!o||o.collectionId!==s.collectionId||o.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const o=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(o.has(c)){s.parentFolderId=void 0;break}o.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!za(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!za(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!za(t,"runIndex")||!za(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,o])=>[s,o]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=mo();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function oy(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),o=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:o,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:o,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=o=>{if(o.length<=e)return e-=o.length,o;const c=o.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(o=>({...o,value:r(o.value)}))),s.formData&&(s.formData=s.formData.map(o=>({...o,value:r(o.value)}))),{request:s,truncated:n}}function ay(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),o={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:mo()};return{...t,history:[o,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),o=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!o.has(c.id);){if(o.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function hf(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function pf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),o=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,o=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});o=!0}if(!o)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:mo()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let o=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=o.filter(w=>w.key.trim()!==h);v.length!==o.length&&(o=v,c=!0);continue}const g=o.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];o[v]={...o[v],key:h,value:b,enabled:!0},g.length>1&&(o=o.filter((w,A)=>A===v||w.key.trim()!==h))}else o.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:o,updatedAt:mo()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=mo();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const o=e.transaction(tl,"readonly").objectStore(tl).get(t);o.onsuccess=()=>n(AC(t,oy(o.result))),o.onerror=()=>r(o.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const o=n.transaction(tl,"readwrite");o.objectStore(tl).put(Z0(e),t),o.oncomplete=()=>r(),o.onerror=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace")),o.onabort=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),o=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{o.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,o.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function mf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,o=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:mf(O,.5),p95Ms:mf(O,.95),p99Ms:mf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),o=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:o===null?null:new Date(o).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,o=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const gf=zC();function VC(t){gf.record(t)}function FC(){return gf.snapshot()}function PC(){gf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function yf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=yf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Fa(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,o]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${o}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Pa(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&po(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,o=t.hostExecution?.preferHostExecution,c=o===!1?!1:t.preferHostExecution??s??o??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Pa({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:o}of n){const c=s.file;r.append(`formData[${o}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=yf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let o=yf(t.request),c=Fa(t.variables),u=Fa(t.collectionVariables);const f=Fa(t.externalVariables);let h=Fa(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(o=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(o={...o,auth:t.resolveAuth(o.auth)}),o=nC(o,c),w=(o.method||"GET").toUpperCase(),A=o.url;const[j,,,R]=Pa({request:o,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(o);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(o);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function bf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:o="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":o,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Ya(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const o of e)n+=String.fromCharCode(o);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function oN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),o=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",o),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Ya(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function aN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||aN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const o=vy(48),c=await oN(o);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:o}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,o=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:o,scope:typeof n.scope=="string"?n.scope:void 0}}async function Ka(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},o=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&o?s.Authorization=`Basic ${lN(`${o}:${t.clientSecret||""}`)}`:(o&&e.set("client_id",o),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),o=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-osetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}const s=await cN(t,e.windowObject),o=await dN(s,e);if((o.searchParams.get("state")||new URLSearchParams(o.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(o.hash.replace(/^#/,"")),f=o.searchParams.get("error")||u.get("error");if(f){const b=o.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=o.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Ka(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Ya(t);return s&&r.set("scope",s),Ka(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,o]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{o(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{o(!1)}},w=async()=>{o(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{o(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},xf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:o,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>o(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>o({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:o}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>o({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>o({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>o({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>o({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>o({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>o({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>o({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>o({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>o({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>o({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>o({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>o({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>o({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>o({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>o({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>o({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>o({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>o({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let vf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=wf(t,e);for(e+=jy(r);e=0&&Ay(wf(t,c));)o++,c-=2;if(o%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new go(this),o=new go(e);for(let c=n,u=n;;){if(s.next(c),o.next(c),c=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new go(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.text[o],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let o=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ga(o.text,c.text.slice(),0,o.length);if(u.length<=32)r.push(new Vt(u,c.length+o.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ga(this.text,Ga(r.text,Ey(this.text,0,e)),n),o=this.length+r.length-(n-e);return s.length<=32?new Vt(s,o):Hi.from(Vt.split(s,[]),o)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;o<=n&&ce&&c&&(s+=r),eo&&(s+=u.slice(Math.max(0,e-o),n-o)),o=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let o of e)r.push(o),s+=o.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.children[o],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let o=0,c=0;c<=n&&o=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=o&&n<=u){let f=c.replace(e-o,n-o,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;oe&&o&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,o,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,o+=n){if(s==c||o==u)return r;let f=this.children[s],h=e.children[o];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),o=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>o&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ga(t,e,n=0,r=1e9){for(let s=0,o=0,c=!0;o=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],o=this.offsets[r],c=o>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new go(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},go.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const Sf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return o+(e-s);o+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?o:o+f;o+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Af(this,(n,r,s,o,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return kf(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,o=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,o.text),o.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],o=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||Sf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(o,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,o,g,b),s=h,o=g}}}function kf(t,e,n,r=!1){let s=[],o=r?[]:null,c=new yo(t),u=new yo(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),o.forward2(f),c.forward(f)}}}}class yo{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-o.from),n=e.indexOf(r);for(let s=1;so.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Cf=0;class Ue{constructor(e,n,r,s,o){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=Cf++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Nf),!!e.static,e.enables)}of(e){return new Xa([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Nf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Xa{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=Cf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,o=this.id,c=e[o]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Tf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[o];if(A!=null){let C=Za(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),o=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Ja).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let o=r.values[n],c=this.updateF(o,s);return this.compareF(o,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let o=r.facet(Ja),c=s.facet(Ja),u;return(u=o.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Ja.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function bo(t){return e=>new Ly(e,t)}const Qa={highest:bo(Ns.highest),high:bo(Ns.high),default:bo(Ns.default),low:bo(Ns.low),lowest:bo(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new jf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Wa{constructor(e,n,r,s,o,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=o,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],o=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(o[v.facet.id]||(o[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in o){let w=o[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Nf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Wa(e,c,b,u,f,o)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function o(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof jf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)o(h,u);else if(c instanceof jf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),o(h,u)}else if(c instanceof Ly)o(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&o(c.provides,u);else if(c instanceof Xa)r[u].push(c),c.facet.extensions&&o(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(h,u)}}return o(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function xo(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Za(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),Ef=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let o=s.map(n);o&&r.push(o)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,o,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=o,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),o.some(u=>u.type==rn.time)||(this.annotations=o.concat(rn.time.of(Date.now())))}static create(e,n,r,s,o,c){return new rn(e,n,r,s,o,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let o,c;if(r=t[r]))o=t[r++],c=t[r++];else if(s=0;s--){let o=r[s](t);o instanceof rn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof rn?t=o[0]:t=Vy(e,sl(o),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let o=n[s](t);o&&Object.keys(o).length&&(r=Uy(r,Of(e,o,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Mf;try{Mf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Mf)return Mf.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,o,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let o;n?o=e.startState.values.slice():(n=Wa.resolve(r,s,this),o=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(Ef)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),o=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Wa.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||Sf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(Ef)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(o,c)=>c.create(o),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>n.length?r:n[o-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let o of this.facet(qy))for(let c of o(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(o(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Rf(t,e,n={}){let r={};for(let s of t)for(let o of Object.keys(s)){let c=s[o],u=r[o];if(u===void 0)r[o]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,o))r[o]=n[o](u,c);else throw new Error("Config merge conflict for field "+o)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return _f.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Df(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let _f=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function Lf(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class qf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let o=r?this.to:this.from;for(let c=s,u=o.length;;){if(c==u)return c;let f=c+u>>1,h=o[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let o=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,o);oE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}o(C,E,v)}}return{mapped:c.length?new qf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:o=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(Lf)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new vo;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new vo),o.addRange(f,h,g,!1)};for(let f=0;f=o&&e<=o+c.length&&c.between(o,e-o,n-o,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return wo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return wo.from(e).goto(n)}static compare(e,n,r,s,o=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),f=Fy(c,u,r),h=new So(c,f,o),g=new So(u,f,o);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let o=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(o.length!=c.length)return!1;if(!o.length)return!0;let u=Fy(o,c),f=new So(o,u,0).goto(r),h=new So(c,u,0).goto(r);for(;;){if(f.to!=h.to||!$f(f.active,h.active)||f.point&&(!h.point||!Df(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,o=-1){let c=new So(e,null,o).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new vo;for(let s of e instanceof _f?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(Lf);e=r}return t}mt.empty.nextLayer=mt.empty;class vo{finishChunk(e){this.chunks.push(new qf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new vo)).addRange(e,n,r,s)}addInner(e,n,r,s){let o=e-this.lastTo||r.startSide-this.last.endSide;if(s&&o<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let o of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,o));return s.length==1?s[0]:new wo(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),Bf(this.heap,0)}}}function Bf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class So{constructor(e,n,r){this.minPoint=r,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=wo.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){ec(this.active,e),ec(this.activeTo,e),ec(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:o}=this.cursor;for(;n0;)n++;tc(this.active,n,r),tc(this.activeTo,n,s),tc(this.activeRank,n,o),e&&tc(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&ec(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,o){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!o.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Df(t.point,n.point)&&$f(t.activeForPoint(t.to),n.activeForPoint(n.to))||o.comparePoint(u,A,t.point,n.point),g=!1):(g&&o.boundChange(u),A>u&&!$f(t.active,n.active)&&o.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function $f(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;o+=t.charCodeAt(s)==9?n-o%n:1,s=kn(t,s)}return t.length}const If="ͼ",Gy=typeof Symbol>"u"?"__"+If:Symbol.for(If),Hf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ol{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function o(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))o(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");o(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)o(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,If+e.toString(36)}static mount(e,n,r){let s=e[Hf],o=r&&r.nonce;s?o&&s.setNonce(o):s=new IN(e,o),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let o=Jy.get(r);if(o)return e[Hf]=o;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Hf]=this}mount(e,n){let r=this.sheet,s=0,o=0;for(let c=0;c-1&&(this.modules.splice(f,1),o--,f=-1),f==-1){if(this.modules.splice(o++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Ao[dn]=String.fromCharCode(dn);for(var zf in $r)Ao.hasOwnProperty(zf)||(Ao[zf]=$r[zf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ao:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Uf=typeof document<"u"?document:{documentElement:{style:{}}};const Vf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Ff=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),ic=!!(Qy||Ff||Vf),Wy=!ic&&/gecko\/(\d+)/i.test(Dn.userAgent),Pf=!ic&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in Uf.documentElement.style,Yf=!ic&&/Apple Computer/.test(Dn.vendor),eb=Yf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:ic,ie_version:Qy?Uf.documentMode||6:Ff?+Ff[1]:Vf?+Vf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Pf,chrome_version:Pf?+Pf[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Yf,safari_version:Yf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:Uf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Kf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const rc=Object.create(null);function Gf(t,e,n){if(t==e)return!0;t||(t=rc),e||(e=rc);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let o of r)if(o!=n&&(s.indexOf(o)==-1||t[o]!==e[o]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:o,end:c}=nb(e,n);r=(o?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new Co(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}on.none=mt.empty;class ko extends on{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Kf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||rc}eq(e){return this==e||e instanceof ko&&this.tagName==e.tagName&&Gf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}ko.prototype.point=!1;class Co extends on{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Co&&this.spec.class==e.spec.class&&Gf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Co.prototype.mapMode=Wn.TrackBefore,Co.prototype.point=!0;class js extends on{constructor(e,n,r,s,o,c){super(n,r,o,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function al(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class No extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof No&&this.tagName==e.tagName&&Gf(this.attributes,e.attributes)}static create(e){return new No(e.tagName,e.attributes||rc,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}No.prototype.startSide=No.prototype.endSide=-1;function To(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Xf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function jo(t,e){if(!e.anchorNode)return!1;try{return Xf(t,e.anchorNode)}catch{return!1}}function lc(t){return t.nodeType==3?Oo(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Eo(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function oc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,o,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+o)):e.right>v.right-o&&(E=e.right-v.right+o,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let o=t.parentNode;o&&!(o==n.body||(!e||r)&&s);)if(o.nodeType==1)!s&&o.scrollHeight>o.clientHeight&&(s=o),e&&!r&&o.scrollWidth>o.clientWidth&&(r=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:r,y:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ob(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ab(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ob(e))}let cb;function Oo(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),o.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!oc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(o<0||(s!=0?s<0?u.fromn:e[o].level>u.level))&&(o=c)}}if(o<0)throw new RangeError("Index out of range");return o}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?o:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,o=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else o=h,f++}}}function Wf(t,e,n,r,s,o,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Zf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Wf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>o[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==o[h-1].to){if(b)break e;let C=o[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&o[D-1].to==E)E=o[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Zf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var o;let c=r.head-t.from,u=Vi.find(e,c,(o=r.bidiLevel)!==null&&o!==void 0?o:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,o,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=o,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const cc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(uc.of(h=>{let g=h.plugin(u);return g?c(g):on.none})),o&&f.push(o(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class ih{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),rh=Ue.define(),uc=Ue.define(),Eb=Ue.define(),sh=Ue.define(),Mo=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(o=>o instanceof Function?o(t):o),s=[];return mt.spans(r,e.from,e.to,{point(){},span(o,c,u,f){let h=o-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let o of t.state.facet(Rb)){let c=o(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ro=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(o,c,u,f))),this.changedRanges=s}static create(e,n,r){return new dc(e,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}}const oT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return oT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 hc)return e;return null}static get(e){return e.cmTile}}class fc extends Ht{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 n=this.dom,r=null,s,o=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,o&&s!=u.dom&&(o.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,o&&s&&(o.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hc extends fc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,o=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&o++,s=n.pop()}else{let c=r.children[s++];if(c instanceof or)n.push(s),r=c,s=0;else{let u=o+c.length,f=e(c,o);if(f!==void 0)return f;o=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,o,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,c=e-f)}}),!r&&!o)throw new Error("No tile at position "+e);return r&&n<0||!o?{tile:r,offset:s}:{tile:o,offset:c}}}class or extends fc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new or(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends fc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,o=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,o=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?o:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):aT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:o}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,o)):s.domPosFor(o,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function aT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=lc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let o=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(o--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let o=this.dom.getClientRects(),c=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;c=o[f],!(e>0?f==0:f==o.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:o,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(o==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:o}=u.pop(),o++}else{let f=s.children[o],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(lh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(lh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let o=Ht.get(e.text);o&&this.cache.reused.set(o,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let o=this.ensureMarks(n,r);!s&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let o=e.length-1;o>=0;o--){let c=e[o],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(oh,0,32)||new Rs(oh.toDOM(),0,oh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(o),n=o}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(pc,void 0,1);return r&&(r.flags=n),r||new pc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:o,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return o?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const mc=[Rs,fl,Ms,Hn,pc,or,hc];for(let t=0;t[]),this.index=mc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,o=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,o=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,o+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=o=0):c instanceof Hn&&(s.shift(),o=Math.min(o,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,o=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>o),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let o=Ht.get(s);if(s==this.view.contentDOM)break;o instanceof Hn?n.push(o):o?.isLine()?r=o:o instanceof or||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new ko({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Kf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function lh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends sc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const oh=new class extends sc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=on.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 hc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let o=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Oe.ie||Oe.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),o&&!r.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(r=o.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 o=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||r.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&jo(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(o||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!Eo(h.node,h.offset,b.anchorNode,b.anchorOffset)||!Eo(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=To(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=To(e.root),{anchorNode:s,anchorOffset:o}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,o)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let o;if(e==r.dom)o=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?o=e:o=e.nextSibling}if(o==r.dom.firstChild)return s;for(;o&&!Ht.get(o);)o=o.nextSibling;if(!o)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,o=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(o=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,o=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(o&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:o}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof ch?null:s.coordsInWidget(o,n,!0):s.coordsIn(o,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(o,c){if(o.isComposite())for(let u of o.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(o.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof or)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?lc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=o,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=lc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,o;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=lc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,o=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:o}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let o=s==n.viewports.length?null:n.viewports[s],c=o?o.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(on.replace({widget:new ch(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!o)break;r=o.to+1}return on.set(e)}updateDeco(){let e=1,n=this.view.state.facet(uc).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),r=!1,s=this.view.state.facet(sh).map((o,c)=>{let u=typeof o=="function";return u&&(r=!0),u?o(this.view):o});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Db(this.view),c={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),o=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=r,!o)return null;let c=e-o.offset;return{from:c,to:c+o.node.nodeValue.length,node:o.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:o,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(o),f.mapPos(c),o,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class ch extends sc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(s.length==0)return ke.cursor(e);o==0?n=1:o==s.length&&(n=-1);let c=o,u=o;n<0?c=kn(s.text,o,!1):u=kn(s.text,o);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);o+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,o,t.state.tabSize)}function uh(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let o of r.type){if(o.from>e)break;if(!(o.toe)return o;(!s||o.type==fn.Text&&(s.type!=o.type||(n<0?o.frome)))&&(s=o)}}return s||r}return r}function OT(t,e,n,r){let s=uh(t,e.head,e.assoc||-1),o=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(o){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(o.top+o.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,o,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),o=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return o=>{let c=r(o);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,o=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=o<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(o<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*o,E=fh(t,{x:b,y:C},!1,o);if(n?C>f.bottom:Cu:O{if(e>o&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+o:v.bottom>=f+o))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=o&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let o=0;o{let c=r[o]-n,u=r[o+1]-n;return Oo(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Oo(f.dom,0,f.length)).getClientRects()}),o=e.children[s.i],c=r[s.i];return o.isText()?this.scanText(o,c):o.isComposite()?this.scanTile(o,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let o=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:oc(s))||oc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>o)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,c=1,u;if(this.lineSeparator?(o=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(o=u.index,c=u[0].length),this.append(n.slice(r,o<0?n.length:o)),o<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=o+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:o,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=o||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!Xf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Xf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,o=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,o=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:o,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,o=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=o.from,g=null;(c===8||Oe.android&&e.text.length=u&&o.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&b.slice(o.to-u)==e.text.slice(v=e.text.length-(b.length-(o.to-u)))?n={from:o.from,to:o.to,insert:gt.of(e.text.slice(o.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||gc(r,o))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(o.from).toDate.now()-50?n={from:o.from,to:o.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:o.from,to:o.to,insert:gt.of([" "])}),n)return hh(t,n,r,c);if(r&&!gc(r,o)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Mo).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function hh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,o,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,o=s.selection.main,c=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=o.frome.to?s.sliceDoc(e.to,o.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(o.head);let w=o.to-e.to;r=s.changeByRange(A=>{if(A.from==o.from&&A.to==o.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-o.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),o=0;for(;o0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,o-Math.min(c,u));n-=c+f-o}if(c=c?o-n:0;o-=f,u=o+(u-c),c=o}else if(u=u?o-n:0;o-=f,c=o+(c-u),u=o}return{from:o,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||o!=r)&&e.push(new zb(s,o))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function gc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let o in n)if(o!="scroll"){let c=!n[o].handlers.length,u=r[o];u&&c!=!u.handlers.length&&(s.removeEventListener(o,this.handleEvent),u=null),u||s.addEventListener(o,this.handleEvent,{passive:c})}for(let o in r)o!="scroll"&&!n[o]&&s.removeEventListener(o,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,o=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],yc=6;function bc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Mo).map(c=>c(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,o=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+yc?n=-bc(s-e.clientX):e.clientX+f.right>=c-yc&&(n=bc(e.clientX-c)),e.clientY-f.top<=o+yc?r=-bc(o-e.clientY):e.clientY+f.bottom>=u-yc&&(r=bc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=To(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function xc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=xc(t.state,th,e);let{state:n}=t,r,s=1,o=n.toText(e),c=o.lines==n.selection.ranges.length;if(ph!=null&&n.selection.ranges.every(f=>f.empty)&&ph==o.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?o.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=o.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(o);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ab(t.contentDOM);let o=t.root.activeElement;o&&!o.contains(t.contentDOM)&&o.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),o=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:o.from,u=s?s.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(o){o.docChanged&&(n.pos=o.changes.mapPos(n.pos),s=s.map(o.changes))},get(o,c,u){let f=t.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let o=s.posAtStart,c=o+s.length;(o>=n.to||c<=n.from)&&(n=ke.undirectionalRange(o,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",xc(t.state,nh,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=xc(t.state,th,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,c=r&&o&>(t,e)?{from:o.from,to:o.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,o=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),o()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let c=t.doc.lineAt(o);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:xc(t,nh,e.join(t.lineBreak)),ranges:n,linewise:r}}let ph=null;Mi.copy=Mi.cut=(t,e)=>{if(!jo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;ph=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=Gb?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let o=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(o&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return hh(t,{from:f,to:h,insert:t.state.toText(o)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(o=>o.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>o+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ox(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=o,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>vc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let o=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=o.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:o.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fo*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(o>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,o-=u.size}else break;else if(s=o&&c(this.lineAt(0,Rt.ByPos,r,s,o))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ax{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,o=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);c=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else c=this.height/o;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:o,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let o=r[r.length-1];o instanceof hn?r[r.length-1]=new hn(o.length+s):r.push(null,new hn(s-1))}if(e>0){let o=r[0];o instanceof hn?r[0]=new hn(e+o.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let o=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=o&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=vc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=o&&c.push(null,new hn(o-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=vc||Math.abs(f-this.heightMetrics(e,n).perLine)>=vc)&&(ml=!0),wc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class oj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let o=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,o).join(h)}forEachLine(e,n,r,s,o,c){let u=s+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,o);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let o=[];e>0&&this.decomposeLeft(e,o);let c=o.length;for(let u of r)o.push(u);if(e>0&&cx(o,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=wc(this.left,e),this.right=wc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:o,right:c}=this,u=n+o.length+this.break,f=null;return s&&s.from<=n+o.length&&s.more?f=o=o.updateHeight(e,n,r,s):o.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(o,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const aj=5;class mh{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=aj)&&this.addLineDeco(s,o,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();o=Math.max(o,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:o-n.left,right:Math.max(o,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class gh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=on.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:o,to:c})=>s>=o&&s<=c)){let{from:o,to:c}=this.lineBlockAt(s);e.push(new Sc(o,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new yh(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(_o(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,o=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ox(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,o=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(o,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ox();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,o=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new Sc(s.lineAt(c-r*1e3,Rt.ByHeight,o,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,o,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,o,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&o>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new gh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(o,c){r.push({from:o,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||_o(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||_o(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return _o(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}}class Sc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,o=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),o+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:o,to:c}=e[s],u=c-o;if(r<=u)return o+r;r-=u}}function kc(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(uc).filter(r=>typeof r!="function"),n=t.facet(sh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class yh{constructor(e,n,r){let s=0,o=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-o)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),o=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let o=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function _o(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>_o(s,e)):t._content)}const Cc=Ue.define({combine:t=>t.join(" ")}),bh=Ue.define({combine:t=>t.indexOf(!0)>-1}),xh=ol.newName(),hx=ol.newName(),px=ol.newName(),mx={"&light":"."+hx,"&dark":"."+px};function vh(t,e,n){return new ol(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=vh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),wh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!jo(this.dom,s))return;let o=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&Eo(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=To(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=jo(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&cl(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let o of e){let c=this.readMutation(o);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&jo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!gc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return Eo(c.node,c.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:o,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&othis.to&&(f=o);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));gc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);hh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],o=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let o of r.getTextFormats()){let c=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),h=this.toEditorPos(o.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=To(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((o,c,u,f,h)=>{if(r)return;let g=h.length-(c-o);if(s&&c>=s.to)if(s.from==o&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(o+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(othis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(o=>r(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(cc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new ih(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,o=this.state;for(let v of e){if(v.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=v.state}if(this.destroyed){this.viewState.state=o;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(o,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(g=null)):this.observer.clear(),o.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(o);s=dc.create(this,o,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(cc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Nc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Cc)!=s.state.facet(Cc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(eh))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new ih(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let o of r){let c=n.indexOf(o);if(c<0)s.push(new ih(o));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))o=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);o=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=dc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?o<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(eh))f(n)}get themeClasses(){return xh+" "+(this.state.facet(bh)?px:hx)+" "+this.state.facet(Cc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,rh,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),o=tb(this.dom,this.editorAttrs,e);return s||o});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let e=this.state.facet(Xe.cspNonce);ol.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return dh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return dh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),o=r[n?r.length-1:0];return ke.cursor(o.side(n,s)+e.from,o.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return dh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=fh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),fh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,o.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==n&&(o.fresh||mb(o.isolates,r=Mb(this,e))))return o.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Nc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(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,n={}){var r,s,o,c;return cc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(o=n.yMargin)!==null&&o!==void 0?o:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return cc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=ol.newName(),s=[Cc.of(r),Ro.of(vh(`.${r}`,e))];return n&&n.dark&&s.push(bh.of(!0)),s}static baseTheme(e){return Qa.lowest(Ro.of(vh("."+xh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ro,Xe.inputHandler=Sb,Xe.clipboardInputFilter=th,Xe.clipboardOutputFilter=nh,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=eh,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=uc,Xe.blockWrappers=Eb,Xe.outerDecorations=sh,Xe.atomicRanges=Mo,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=bh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=rh,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Nc{constructor(e,n,r,s,o,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=o,this.order=c}static update(e,n){if(n.empty&&!e.some(o=>o.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let o=Math.max(0,e.length-10);o=0;s--){let o=r[s],c=typeof o=="function"?o(t):o;c&&Kf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,o,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},o=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,Sh))}let f=c[e]||c.key;if(f)for(let h of u)o(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&o(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let Sh=null;function Ej(t,e,n,r){Sh=e;let s=UN(e),o=kN(s,0),c=CN(o)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Tc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Tc(A,e,!0)])||e.shiftKey&&(C=Ao[e.keyCode])!=s&&C!=A&&v(w[u+Tc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Tc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),Sh=null,f}class Ds{constructor(e,n,r,s,o){this.className=e,this.left=n,this.top=r,this.width=s,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let o=Sx(e);return[new Ds(n,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let o=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:o.left+1,y:c}),f=t.posAtCoords({x:o.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),o=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=uh(t,r,1),A=uh(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;we>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(we,q),L==null&&we>=be,ae.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(jc)!=e.state.facet(jc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(jc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const jc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),jc.of(t)]}const gl=Ue.define({combine(t){return Rf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(o&&Oe.ios&&n.iosSelectionHandles)){let c=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let o of Ds.forRange(t,"cm-selectionBackground",s))e.push(o);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Qa.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=on.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return on.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const Ec=Ue.define(),Hj=Ue.define(),Oc=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Oc).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Ec),this.view.viewport.from),r=[],s=this.gutters.map(o=>new Vj(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let c=!0;for(let u of o.type)if(u.type==fn.Text&&c){Ah(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(o.type==fn.Text){Ah(n,r,o.from);for(let c of s)c.line(this.view,o,r)}else if(o.widget)for(let c of s)c.widget(this.view,o);for(let o of s)o.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Oc),n=t.state.facet(Oc),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Ec),t.state.facet(Ec),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let o of n){let c=e.indexOf(o);c<0?s.push(new Ox(this.view,o)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let o of this.gutters)o.dom.remove(),s.indexOf(o)<0&&o.destroy();for(let o of s)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Ah(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,o=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,o,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,o,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Ah(this.cursor,s,n.from),r.length&&(s=s.concat(r));let o=this.gutter.config.lineMarker(e,n,s);o&&s.unshift(o);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let o of e.state.facet(Hj)){let c=o(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let o=s.target,c;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let o=0,c=0;;){let u=c,f=oo(u,f,h)||c(u,f,h):c}return r}})}});class kh extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ch(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Oc.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new kh(Ch(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let o=s(e,n,r);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new kh(Ch(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=Ch(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new kh(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Nh{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class Lo{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(s)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return s}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 n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),o=-1;o<(s?s.length:0);o++){let c=n[o<0?r.name:s[o]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Mc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,o){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,o&&o.length){this.props=Object.create(null);for(let[c,u]of o)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=Lo.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Eh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Mc.get(this)||this.topNode,o=new Eh(s);return o.moveTo(e,n),Mc.set(this,o._tree),o}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=qo(Mc.get(this)||this.topNode,e,n,!1);return Mc.set(this,r),r}resolveInner(e,n=0){let r=qo(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:o=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=o&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Mh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Th{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Th(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,o=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function qo(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(o&Pt.EnterBracketed&&g instanceof pn&&(v=Lo.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(o&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(o&Pt.IncludeAnonymous||!g.type.isAnonymous||Oh(g)){let w;if(!(o&Pt.IgnoreMounts)&&(w=Lo.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return o&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,o)}}}if(o&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=Lo.get(this._tree))&&s.overlay){let o=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=o:u=o:f>o))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return o}for(;;){if(r!=null&&s.type.is(r))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return r==null?o:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,o=r.buffer[this.index+3];if(o>s){let c=r.buffer[this.index+1];e.push(r.slice(s,o,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let o=1;on.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+o.from,-1,o);(s||(s=[r])).push(qo(u,e,n,!1))}}return s?Ix(s):r}class Eh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let o=n+e,c=e<0?-1:r._tree.children.length;o!=c;o+=e){let u=r._tree.children[o];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Oh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=o+1;break e}s=this.stack[--o]}for(let s=r;s=0;o--){if(o<0)return jh(this._tree,e,s);let c=r[n.buffer[this.stack[o]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Oh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Oh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:o=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Th(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=o[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],ae,he,we=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);ae=new Ur(T,be-he.start,r),we=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);ae=Mh(J,z,me,0,z.length,0,be-ee,qe,qe)}else ae=C(J,z,me,be-ee,ge-be,q)}M.push(ae),G.push(we)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(yt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[yt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[yt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Rc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Rc(t,r)}Hx.set(e,n)}return n}function Mh(t,e,n,r,s,o,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Mh(t,A,C,R,j,_,M,null,f))}v.push(_+O-o)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,o=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(o?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let o of n)o.to>e.length&&s.push(o);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],o=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=onew Nh(s.from,s.to)):[new Nh(0,0)]:[new Nh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let o=s.advance();if(o)return o}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let o of n.set)s.set.push(o);return s}static defineModifier(e){let n=new Dc(e);return r=>r.modified.indexOf(n)>-1?r:Dc.get(r.base||r,r.modified.concat(n).sort((s,o)=>s.id-o.id))}}let lE=0;class Dc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&oE(n,u.modified));if(r)return r;let s=[],o=new yi(e.name,s,e,n);for(let u of n)u.instances.push(o);let c=aE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Dc.get(u,f));return o}}function oE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function aE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let o=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(o.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=o.length-1,h=o[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new _c(r,c,f>0?o.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let o=new _c(s.tags,s.mode,s.context);n?n.next=o:r=o,n=o}return r}});class _c{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of o)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const Ee=yi.define,Lc=Ee(),Fr=Ee(),zx=Ee(Fr),Ux=Ee(Fr),Pr=Ee(),qc=Ee(Pr),Rh=Ee(Pr),Yi=Ee(),Ls=Ee(Yi),Ki=Ee(),Gi=Ee(),Dh=Ee(),Bo=Ee(Dh),Bc=Ee(),rt={comment:Lc,lineComment:Ee(Lc),blockComment:Ee(Lc),docComment:Ee(Lc),name:Fr,variableName:Ee(Fr),typeName:zx,tagName:Ee(zx),propertyName:Ux,attributeName:Ee(Ux),className:Ee(Fr),labelName:Ee(Fr),namespace:Ee(Fr),macroName:Ee(Fr),literal:Pr,string:qc,docString:Ee(qc),character:Ee(qc),attributeValue:Ee(qc),number:Rh,integer:Ee(Rh),float:Ee(Rh),bool:Ee(Pr),regexp:Ee(Pr),escape:Ee(Pr),color:Ee(Pr),url:Ee(Pr),keyword:Ki,self:Ee(Ki),null:Ee(Ki),atom:Ee(Ki),unit:Ee(Ki),modifier:Ee(Ki),operatorKeyword:Ee(Ki),controlKeyword:Ee(Ki),definitionKeyword:Ee(Ki),moduleKeyword:Ee(Ki),operator:Gi,derefOperator:Ee(Gi),arithmeticOperator:Ee(Gi),logicOperator:Ee(Gi),bitwiseOperator:Ee(Gi),compareOperator:Ee(Gi),updateOperator:Ee(Gi),definitionOperator:Ee(Gi),typeOperator:Ee(Gi),controlOperator:Ee(Gi),punctuation:Dh,separator:Ee(Dh),bracket:Bo,angleBracket:Ee(Bo),squareBracket:Ee(Bo),paren:Ee(Bo),brace:Ee(Bo),content:Yi,heading:Ls,heading1:Ee(Ls),heading2:Ee(Ls),heading3:Ee(Ls),heading4:Ee(Ls),heading5:Ee(Ls),heading6:Ee(Ls),contentSeparator:Ee(Yi),list:Ee(Yi),quote:Ee(Yi),emphasis:Ee(Yi),strong:Ee(Yi),link:Ee(Yi),monospace:Ee(Yi),strikethrough:Ee(Yi),inserted:Ee(),deleted:Ee(),changed:Ee(),invalid:Ee(),meta:Bc,documentMeta:Ee(Bc),annotation:Ee(Bc),processingInstruction:Ee(Bc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var _h;const $c=new yt,fE=new yt;class ar{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((o,c,u)=>{let f=Vx(o,c,u),h=f.type.prop($c);if(!h)return[];let g=o.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,o)){let A=o.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop($c)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(o,c)=>{if(o.prop($c)==this.data){r.push({from:c,to:c+o.length});return}let u=o.prop(yt.mounted);if(u){if(u.tree.prop($c)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+o.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let $o=null;class Ic{constructor(e,n,r=[],s,o,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=o,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Ic(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=$o;$o=this;try{return e()}finally{$o=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:o,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,o=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let o=s[0].from,c=s[s.length-1].to;return{parsedPos:o,advance(){let f=$o;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return $o}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Ic.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}ar.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(ar.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Lh=typeof navigator<"u"&&(!((_h=navigator.scheduling)===null||_h===void 0)&&_h.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=o.context.work(()=>Lh&&Lh()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ar.setState.of(new bl(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[ar.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),qh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Hc(t){let e=t.facet(qh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function zc(t,e){let n="",r=t.tabSize,s=t.facet(qh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let o=0;o=e?yE(t,n,e):null}class Uc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Hc(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:o}=this.options;return s!=null&&s>=r.from&&s<=r.to?o&&s==e?{text:"",from:e}:(n<0?s-1&&(o+=c-this.countColumn(r,r.search(/\S|$/))),o}countColumn(e,n=e.length){return nc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),o=this.options.overrideIndentation;if(o){let c=o(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let o=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)o.push(c);for(let c=o.length-1;c>=0;c--)r={node:o[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(Bh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,o=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,o&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class Bh extends Uc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Bh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(n.from),c=s==null||s<=o.from?o.to:Math.min(o.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let o=t.textAfter,c=o.match(/^\s*/)[0].length,u=r&&o.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function $h(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function Ih(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,o=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=$h(f.type,n,o);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,o)}}return jE(t,e,n,c,u.type,s,o)}function TE(t,e,n,r,s,o,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&o.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=o;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Hh(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Hh(h,`Modifier ${h} used at start of tag`):f.length?Hh(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Hh(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),o=Jx[s];if(o)return o.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Uh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function zh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=zh($E,0),_E=zh(Qx,0),LE=zh((t,e)=>Qx(t,e,BE(e)),0);function Uh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Io=50;function qE(t,{open:e,close:n},r,s){let o=t.sliceDoc(r-Io,r),c=t.sliceDoc(s,s+Io),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(c)[0].length,h=o.length-u;if(o.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*Io?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+Io),b=t.sliceDoc(s-Io,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(o=>Uh(e,o.from).block);if(!r.every(o=>o))return null;let s=n.map((o,c)=>qE(e,r[c],o.from,o.to));if(t!=2&&!s.every(o=>o))return{changes:e.changes(n.map((o,c)=>s[c]?[]:[{from:o.from,insert:r[c].open+" "},{from:o.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(o=>o)){let o=[];for(let c=0,u;cs&&(o==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;vo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&o.push({from:u.from+h,insert:f+" "});let c=e.changes(o);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,o.push({from:h,to:g})}return{changes:o}}return null}const Vh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Rf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Vh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Fc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return o?t=t.addChanges(o,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Fh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Vc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let o=s.pop(t,n,e);return o?(r(o),!0):!1}}const ev=Vc(0,!1),Fh=Vc(1,!1),UE=Vc(0,!0),VE=Vc(1,!0);class zn{constructor(e,n,r,s,o){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=o}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let o=s(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Fc(t,e,n,r){let s=e+1>n+20?e-n-1:0,o=t.slice(s,e);return o.push(r),o}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,o)=>n.push(s,o)),e.iterChangedRanges((s,o,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Fc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Ph(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let o=t.slice(0,n);return o[n-1]=s,o}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(o):o;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(o),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,o){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Pc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function ov(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Pc(n,e))}const JE=t=>ov(t,!Nn(t)),QE=t=>ov(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let o=r.type.prop(s),c,u;return o&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Yc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Yc(t.state,e,Nn(t)));function av(t,e){return _i(t,n=>{if(!n.empty)return Pc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>av(t,!1),uv=t=>av(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Pc(c,e));if(s.eq(r.selection))return!1;let o;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Yh=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(s=ke.cursor(r.from+o))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function oO(t,e,n){let r=!1,s=wl(t.selection,o=>{let c=vl(t,o.head,-1)||vl(t,o.head,1)||o.head>0&&vl(t,o.head-1,1)||o.headoO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let o=n(s);return ke.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Yc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Yc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Gc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),o=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let o of n.selection.ranges){let c=n.doc.lineAt(o.head);if(e?c.to0)for(let u=o;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ho(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(o=>{let{from:c,to:u}=o;if(c==u){let f=e(o);fc&&(n="delete.forward",f=Kc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Kc(t,c,!1),u=Kc(t,u,!0);return c==u?{range:o}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,o)=>{se&&(e=n?o:s)});return e}const Ev=(t,e,n)=>Ho(t,r=>{let s=r.from,{state:o}=t,c=o.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ho(t,n=>{let r=n.head,{state:s}=t,o=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?o.to:o.from)){r==n.head&&o.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(o.text,r-o.from,e)+o.from,h=o.text.slice(Math.min(r,f)-o.from,Math.max(r,f)-o.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ho(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headHo(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ho(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,o=t.doc.lineAt(s),c=s==o.from?s-1:kn(o.text,s-o.from,!1)+o.from,u=s==o.to?s+1:kn(o.text,s-o.from,!0)+o.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=o.to,c.ranges.push(r)}else e.push({from:s.from,to:o.to,ranges:[r]});n=o.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let o of Gc(t)){if(n?o.to==t.doc.length:o.from==0)continue;let c=t.doc.lineAt(n?o.to+1:o.from-1),u=c.length+1;if(n){r.push({from:o.to,to:c.to},{from:o.from,insert:c.text+t.lineBreak});for(let f of o.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:o.from},{from:o.to,insert:t.lineBreak+c.text});for(let f of o.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let o of Gc(t))n?r.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):r.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Gc(e).map(({from:s,to:o})=>(s>0?s--:o{let o;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(o=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,o)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),o;return r&&s&&r.to<=e&&s.from>=e&&(o=r.type.prop(yt.closedBy))&&o.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:o,to:c}=s,u=e.doc.lineAt(o),f=!t&&o==c&&qO(e,o);t&&(o=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new Uc(e,{simulateBreak:o,simulateDoubleBreak:!!f}),g=Yx(h,o);for(g==null&&(g=nc(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));cu.from&&o{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let o=t.changes(s);return{changes:s,range:ke.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Uc(t,{overrideIndentation:o=>{let c=n[o];return c??-1}}),s=Gh(t,(o,c,u)=>{let f=Yx(r,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let h=/^\s*/.exec(o.text)[0],g=zc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(qh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let o=nc(s,t.tabSize),c=0,u=zc(t,Math.max(0,o-Hc(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Kh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Yh}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Yh,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Yh,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Kh,shift:Kh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:aO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:o}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),o!==void 0&&(c["aria-expanded"]=String(o)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const zo=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:o=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,ae=J)=>{const he=O.current;if(!he)return;const we=he.state.doc.length,T=Math.max(0,Math.min(J,we)),z=Math.max(0,Math.min(ae,we));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const ae=O.current;if(!ae)return null;const he=Math.max(0,Math.min(J,ae.state.doc.length)),we=ae.coordsAtPos(he);return we?{left:we.left,right:we.right,top:we.top,bottom:we.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,ae=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Qa.highest(Xe.domEventHandlers({keydown:we=>(_.current?.(we),we.defaultPrevented)})),Xe.updateListener.of(we=>{we.docChanged&&!L.current&&j.current(we.state.doc.toString()),(we.selectionSet||we.docChanged)&&R.current?.(we.state.selection.main.head)})]}),he=new Xe({state:ae,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const ae=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(ae.anchor,e.length),head:Math.min(ae.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(o,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});zo.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Xh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(o,c)=>n(e.map((u,f)=>f===o?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((o,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:o.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:o.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:o.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||po(t),s=n==="dark",o=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Xh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(zo,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:o,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Xh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${o}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${o}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Xh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${o}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(zo,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(zo,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const o=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,o]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>o(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>o("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} -});`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;a{const u=a.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` +`).map(o=>{const u=o.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` `)}function Pv(t,e){return t.slice(0,Math.max(0,Math.min(e,t.length))).replace(/\r\n?/g,` `).length}function Yv(t,e,n){const r=t.split(` `),s=e.split(` -`),a=t.slice(0,Math.max(0,Math.min(n,t.length))),c=a.split(` -`).length-1,u=a.lastIndexOf(` -`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),o=t.slice(0,Math.max(0,Math.min(n,t.length))),c=o.split(` +`).length-1,u=o.lastIndexOf(` +`),f=o.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),o=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(o,s.length),selectionEnd:Math.min(Math.max(o,c),s.length)}}const Jh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Jh,"flex.collection":Jh,"flex.variables":Jh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,o)=>s.localeCompare(o)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,o]of r){const c=n.match(s);if(c)return{path:o,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function o3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function a3(t,e,n,r={},s=!1){const o=Math.max(0,Math.min(e,t.length)),c=t.slice(0,o),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:o-u.prefix.length,to:o,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:o-f.prefix.length,to:o,items:v}:null}const h=o3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:o-h.prefix.length,to:o,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:o-g.length,to:o,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:o={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,ae=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,ae))})},j=(B,K,ee=!1)=>{const be=a3(B,K,r,o,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(ao,{className:"h-3.5 w-3.5"}):p.jsx(Od,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(zo,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Xc="API-host execute route",Jc="the execute path";function Qc(t,e){return`${Xc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Qc("was unauthorized",`documentation authentication for ${Jc}`):t===403?Qc("was rejected",`CSRF, same-origin, and authorization middleware for ${Jc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Xc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Xc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Jc}.`:Qc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const o=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await o.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return o.status===429||o.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):o.redirected?Qc("was redirected",`authentication middleware for ${Jc}`):o.ok?`${Xc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(o.status,o.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Qh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Qh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Qh(n);if(!r)return t;const s=Qh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const o=new URL(t),c=`${o.pathname==="/"?"":o.pathname}${o.search}${o.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||po(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:o}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${o}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${o}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),o=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:o}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:o="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",ae=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",we=J||ae||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(ae),[qe,He]=I.useState(he),Je=I.useRef(we),$e=I.useRef(we),[ft,At]=I.useState(null),[bt,Ge]=I.useState(),[Q,re]=I.useState(null),[Se,Ne]=I.useState(null),[Be,We]=I.useState([]),[lt,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),ve=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Te=["GET","HEAD"].includes(Ae),je=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${je}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&o!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Fo=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=po(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Fo},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>o==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${le}-script-tab-${se}`,En=se=>`${le}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&o!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),ve.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Po=E?E(T.auth):T.auth,Qr=Pa({request:{...T,auth:Po},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),lu=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(ft,{...T,auth:Po},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ht(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Be.filter(se=>se.passed).length,Yo=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Yo&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${je}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||$e.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${je}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{ve.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Te&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:je,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:je,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(xf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:o==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>lu(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),o==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${je}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),o==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${je}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(bf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Yo,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(co,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),Se&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Se]}),ft&&p.jsx(QO,{response:ft,theme:s,curlCommand:bt,advanced:o==="advanced"}),Be.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Be.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Be.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),lt.length>0&&p.jsx(Rr,{code:lt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Wh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:o,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(o,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(o||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>hf(K),[K]),ae=t1(D,_)!==t1(w.request,A),he=C==="advanced",we=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Wh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(bf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${we}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&ae&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(La,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${we}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Wh("tab",ne)},onScriptTabChange:ne=>{B(ne),Wh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>pf(Ce,ne))})]})};function Wc(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(t){if(!t)return"";try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"?e.origin:""}catch{return""}}function T3(t,e,n,r){const s=e.startsWith("/")?e:`/${e}`;return{method:t.toUpperCase(),url:n?`${n}${s}`:s,auth:{type:"none"},...r?{hostExecution:{preferHostExecution:!0}}:{}}}function j3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function E3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const O3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:o,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=j3(),h=o??nf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L){if(!(c?.runtimeOnly?.some(lt=>lt.path===e&<.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(lt=>lt.code==="runtime.operation-undocumented"&<.location.path===e&<.location.method?.toUpperCase()===n.toUpperCase())))return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const Se=N3(c?.serverOrigin),Ne=s.tryIt?.hostExecution,Be=Ne?.available===!0&&Ne.preferHostExecution!==!1,We=()=>u?.({request:T3(n,e,Se,Be),serverUrl:Se||void 0,scripts:{preRequest:"",tests:""},requestTab:"params",scriptTab:"pre-request"});return p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsxs("dl",{className:`mt-4 space-y-3 text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:[p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.contractEvidence||"Contract"}),p.jsx("dd",{children:ce?.contractNotDeclared||"OpenAPI does not declare this operation."})]}),p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.runtimeEvidence||"Runtime"}),p.jsx("dd",{children:ce?.runtimeRouteUndocumented||`${n.toUpperCase()} ${e} is registered by the running service.`})]})]}),u&&p.jsxs("button",{type:"button",className:"mt-4 inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:We,children:[p.jsx(La,{className:"h-4 w-4"}),ce?.openApiClient||"Open in API Client"]})]})}if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",ae=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,we={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const Se=!A.has(re);w(Ne=>{const Be=new Set(Ne.key===b?Ne.sections:g);return Be.has(re)?Be.delete(re):Be.add(re),{key:b,sections:Be}}),re==="tryIt"&&E3("tryIt",Se?"1":void 0)},He=(re,Se,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Se}-heading`,children:[p.jsxs("button",{type:"button",id:`${Se}-heading`,"aria-expanded":A.has(Se),onClick:()=>qe(Se),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Se)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(Se)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},$e=(re,Se)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=ae.indexOf(Se),Be=re.key==="Home"?ae[0]:re.key==="End"?ae[ae.length-1]:re.key==="ArrowRight"?ae[(Ne+1)%ae.length]:ae[(Ne-1+ae.length)%ae.length];Je(Be)},ft=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wc(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,bt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{ft()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Cd,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&bt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:bt.map(([re,Se])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof Se=="string"?Se:JSON.stringify(Se)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...we})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,Se])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),Se.schema&&p.jsx(Dr,{spec:t,schema:Se.schema,theme:r,...we}),Se.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Se.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,Se])=>{const Ne=In.isReference(Se)?In.resolveReference(t,Se.$ref):Se;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([Be,We])=>{const lt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:Be}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...we})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),lt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(lt.value??lt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Be)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:ae.map(re=>p.jsx("button",{ref:Se=>{R.current[re]=Se},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:Se=>$e(Se,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function M3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function R3(t,e){let n=M3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function D3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const o of In.getHttpMethods(s)){const c=s[o];n.push({path:r,method:o,operation:c,score:R3(c,o),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const _3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",o=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=D3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:o,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${o}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${o}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${o}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${o}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${o}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${o}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(La,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(La,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${o}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${o}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const L3=typeof n1>"u"?{commit:"unknown"}:n1,q3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=L3,o=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),o]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},B3=(t,e,n)=>t==="dark"?n:e,$3="Runtime intelligence returned an invalid snapshot.",I3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),H3=new Set(["error","warning","info"]),z3=new Set(["pass","warn","fail","partial"]);function sn(){throw new Error($3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&sn(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&sn(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];sn()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&sn(),n}function U3(t){return Ji(t)||sn(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||sn(),t.map(U3)}function V3(t){(!Ji(t)||!Ji(t.location))&&sn();const e=Un(t,"code"),n=Un(t,"severity");(!I3.has(e)||!H3.has(n)||t.location.kind!=="operation")&&sn();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const o=i1(t,"expected");o!==void 0&&(r.expected=o);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),t.disposition!==void 0&&(t.disposition!=="acknowledged"&&sn(),r.disposition="acknowledged"),r}function F3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&sn();const e=Un(t,"status");z3.has(e)||sn();const n=t.findings.map(V3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&sn();const o=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==o&&sn(),{status:e,complete:t.complete,findings:n,summary:r}}function P3(t){Ji(t)||sn(),(!Ji(t.runtime)||!Ji(t.summary))&&sn(),typeof t.discoveryComplete!="boolean"&&sn();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const o=Zh(t,"serverOrigin");if(o&&(r.serverOrigin=o),t.server!==void 0){Ji(t.server)||sn();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&sn(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||sn(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=F3(t.validation)),r}const Y3=60;function K3(t,e,n=Y3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function G3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const X3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:o,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:o},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,o,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=K3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=G3(C.current);if(!J.length)return;const ae=J[0],he=J[J.length-1],we=document.activeElement;q.shiftKey&&(we===ae||!C.current.contains(we))?(q.preventDefault(),he.focus()):!q.shiftKey&&(we===he||!C.current.contains(we))&&(q.preventDefault(),ae.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},J3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function Q3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:o,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=W3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(o)?o.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:Q3(o),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(o)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),J3[D]]},D))]}),o!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function eM(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const tM=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:o,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),o();return}if(j.key!=="Tab"||!f.current)return;const R=eM(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,o]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:o}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:o,children:p.jsx(Md,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(nM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),o())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function nM({result:t,theme:e,messages:n,onSelect:r}){const o=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:o,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code}),u.disposition==="acknowledged"&&p.jsx("span",{children:n?.acknowledgedFinding||"acknowledged"})]}),p.jsx("div",{className:`mt-1 text-xs ${o}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${o}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${o}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:o,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>o?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>o(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function iM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Zc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function eu(t){return Array.isArray(t)?`[${t.map(eu).join(",")}]`:Zc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${eu(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function rM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function o1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){o1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function sM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function a1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let o=n?s.get(n):void 0;for(;o&&!r.has(o.id);)r.add(o.id),o=o.parentFolderId?s.get(o.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const o of t.folders)o.collectionId!==e||!o.parentFolderId||r.has(o.id)||r.has(o.parentFolderId)&&(r.add(o.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const o=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))o.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&o.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function lM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[sM(r)],activeEnvironmentId:r.id}}function oM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=a1(r,e),o=f1(r,e);h1(o,e);const c=lM(r,n.environmentId),u={version:6,collections:[rM(s)],folders:d1(r,e),requests:o,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function aM(t){if(!Zc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function tu(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function cM(t,e){const n=a1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(o=>o.id===e.folderId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(o=>o.id===e.requestId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function uM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function dM(t){if(!Zc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Zc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=aM(t.scope),n=uM(t.workspace),r=oy(n);if(eu(n)!==eu(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");tu(r.collections,"collection"),tu(r.folders,"folder"),tu(r.requests,"request"),tu(r.environments,"environment"),cM(r,e);for(const s of r.requests)o1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function fM(t){return`${JSON.stringify(dM(t),null,2)} +`}function hM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let o=!0;for(;o;){o=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),o=!0)}return s}function Sl(t,e,n){const r=hM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function pM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(o=>o.id===e)?.name||"Deleted collection";if(!n)return r;const s=pM(t.folders.filter(o=>o.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function mM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function gM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const o=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=pf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&mM(E);let j;E.result&&!D&&(s=ay(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(o.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=o.filter(g=>g.cancelled).length,h=o.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:o.length,passed:u,failed:h,cancelled:f,stopped:c,items:o,workspace:s}}function Gr(){return new Date().toISOString()}function yM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const bM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:o,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,Se=(Ne,Be)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:Be}),Se(We.id,Be+1))})};return Se(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),Se(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],Se=new Set;let Ne=K.get(Q);for(;Ne&&!Se.has(Ne.id);)Se.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const Se=oM(h,Q),Ne=new Blob([fM(Se)],{type:"application/json;charset=utf-8"}),Be=URL.createObjectURL(Ne),We=document.createElement("a");We.href=Be,We.download=yM(re),We.click(),setTimeout(()=>URL.revokeObjectURL(Be),0),L("")}catch(Se){L(Se instanceof Error?Se.message:String(Se))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),Se=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:Se,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(Se),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(Se=>({...Se,folders:Se.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},ae=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(Se=>Se.id===M.id?{...Se,variables:[...Se.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:Se)}))},he=(Q,re)=>{if(!M)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Be=>Be.id===M.id?{...Be,variables:Be.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:Se}:Be)}))},we=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter(Be=>Be.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),Se=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:Se,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(Se),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map(Be=>Be.id===j?{...Be,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:Be)}));return}const Se={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,Se]})),R(Se.id),O(Q)},me=Q=>{const re=h.requests.find(Se=>Se.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(Se=>Se.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(Se=>Se.id===Q);g(Se=>LC(Se,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",$e=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),ft=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=be(Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return p.jsxs(kd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Be}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${Be} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},Be),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(lt=>ft(lt,re+1,Ne))]},Q.id)},At=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=Y.filter(lt=>lt.folderId===Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return Be.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Be.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:Be.map($e)})]}),We.map(lt=>At(lt,re+1,Ne))]},Q.id)},bt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>o?.(Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(xf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:ae,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:Se=>he(Q.id,{enabled:Se.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:Se=>he(Q.id,{key:Se.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:Se=>he(Q.id,{value:Se.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>we(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),bt.map(Q=>ft(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(xf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map($e),bt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function Uo(){return new Date().toISOString()}const xM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),o=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=Uo(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!o)return;const w=Uo();e(A=>({...A,environments:A.environments.map(C=>C.id===o.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!o)return;const C=Uo();e(E=>({...E,environments:E.environments.map(D=>D.id===o.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),o&&p.jsx("button",{type:"button","aria-label":`Delete environment ${o.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,o.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),o&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:o.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[o.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),o.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function nu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function vM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",o=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,o,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=nu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function wM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),o=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:o,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const o=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=kd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` -`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${o}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:o,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${o}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":o,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":o}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${o}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${o}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function op(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function AM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=AM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,o)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${o}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const kM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:o,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:o||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>vM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>wM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},ae=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],we=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:ae,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=nu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[op(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:nu(ne)?"text-red-600":j,children:op(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:nu(B)?"text-red-600":j,children:op(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[we,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ot(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?ot(r.value):""}function CM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function ap(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=CM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const o=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return o("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){o("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return o("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){o("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(o("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const o=ot(r.key).trim();return o?[{id:An("variable"),key:o,value:ot(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function NM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(o=>t.includes(o));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function TM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(ot).join(` +`):ot(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,o)=>{const c=ot(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${o}]`,f=TM(s.script,`${u}.script`,n).trim();if(!f)return;const h=NM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function jM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function EM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(o=>{const c=o.indexOf("=");return{key:S1(c>=0?o.slice(0,c):o),value:S1(c>=0?o.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function OM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function MM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=ot(r.key).trim();s&&(n=n.replace(new RegExp(`:${MM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function RM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=OM(t.query),n=ot(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=ot(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(ot).join("."):ot(t.host),o=ot(t.port),c=Array.isArray(t.path)?t.path.map(ot).join("/"):ot(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${o?`:${o}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function DM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function _M(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function LM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function qM(t,e,n,r){const s=_M(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const o=ot(t.mode);if(o==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?ot(c.language):"";return{body:ot(t.raw),contentType:s||LM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(o==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:ot(u.key),value:ot(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(o==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=ot(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:ot(c.query),variables:u},contentType:s||"application/json"}}if(o==="formdata"){const c=Xr(t.formdata).map(f=>{const h=ot(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(ot).filter(Boolean).join(", "):ot(f.src);return{key:ot(f.key),value:h==="text"?ot(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(o==="file"){const c=mn(t.file)?ot(t.file.src):ot(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${o}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function BM(t,e,n,r,s,o,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=ot(f.method).trim().toUpperCase()||"GET",g=RM(f.url),b=DM(f.header),v=qM(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:ap(f.auth,{type:"inherit"},`${c}.auth`,u)},A=EM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:o,updatedAt:o}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=ot(e.name)||"Untitled",o=w1(e.event,`${r}.event`,t.warnings),c=jM(t.inheritedScripts,o);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:ap(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=BM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function $M(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=ot(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=ot(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),o=An("collection"),c={id:o,name:e,auth:ap(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:o,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function IM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=ot(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function HM(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:$M(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:IM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function zM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function UM(t,e){const n=zM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function VM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const FM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,o]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=HM(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?UM(M,G.result):VM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?o({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?o({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):o({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(ao,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function PM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e.folderId);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function YM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const KM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const ae=await gM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(we=>({...we,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(we=>({...we,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(ae.workspace),Y(he=>Object.fromEntries(C.map(we=>{const T=he[we.id]||{status:"pending"};return[we.id,T.status==="pending"&&ae.stopped?{status:"skipped"}:T]}))),M(ae),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(co,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(co,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,ae)=>{const he=G[J.id]||{status:"pending"},we=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=we?.status!==void 0&&we.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:ae+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:PM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(ao,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:YM(he)}),we?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",we.status]}),we?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(Nd,{className:"mr-1 inline h-3.5 w-3.5"}),we.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Vo(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function GM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return po(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function XM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:o="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=GM(t),Y=Sn(e),B=nl(),K=o===!1?{}:j1(o),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[ae,he]=I.useState(Y),[we,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[$e,ft]=I.useState({}),[At,bt]=I.useState(),[Ge,Q]=I.useState(B),[re,Se]=I.useState(B.collections[0]?.id),[Ne,Be]=I.useState(""),We=I.useRef(B.collections[0]?.id),lt=I.useRef(void 0),[ti,Tn]=I.useState(o===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(o===!1)return;let Me=!1;return hy(o).then(Ze=>{Me||(Q(Ze),Se(Ze.collections[0]?.id),Be(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[o]);const x=my(o,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>hf(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,ae),[ce,ae]),V=I.useMemo(()=>XM(ce,ae)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,ae,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),ve=I.useCallback(Me=>{Se(Me),Be("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},le=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),o!==!1&&Vo(o,{requestTab:Me}),C?.(Me)},Te=Me=>{qe(Me),o!==!1&&Vo(o,{scriptTab:Me}),E?.(Me)},je=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>pf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,lt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>ay(Ze,{...Me,collectionId:We.current,folderId:lt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Se(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Be(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),o!==!1&&Vo(o,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{Se(Me),Be(Ze||""),bt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{ft({entryId:Me,runId:Ze}),Je("history")},Fo=()=>ni(Me=>{const Ze=!Me;return o!==!1&&Vo(o,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Fo,children:ht?p.jsx(Ed,{className:"h-4 w-4"}):p.jsx(jd,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(bf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(FM,{onWorkspaceChange:Q,onSelectedCollectionChange:ve,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(xM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(bM,{request:ce,scripts:ae,onLoadRequest:Dt,onSelectedCollectionChange:ve,onSelectedFolderChange:Be,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),o!==!1&&Vo(o,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(kM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:$e.entryId,initialRunId:$e.runId,theme:kt},`${$e.runId||""}:${$e.entryId||""}`):He==="runner"&&At?p.jsx(KM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:we,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:je,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:le,onRequestTabChange:Ae,onScriptTabChange:Te,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function iu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function JM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,o]of Object.entries(t.paths))for(const c of In.getHttpMethods(o)){if(Wc(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function QM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${iu(n.padding.vertical)||"0"} ${iu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:iu(n.maxHeight)||"32px",maxWidth:iu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const WM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const o=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=ho(o),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:o,preferences:c})),ae=I.useRef(null),he=I.useRef(null),we=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===o?q.preferences:ho(o),Je=n&&He.theme||e,$e=Je==="high-contrast"?"dark":Je,ft=He.expand,At=He.expandedTags??["default"],bt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...JM($e,Ge),...r}),[$e,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return P3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const le=R1(t,window.location.hash);if(le){g(le);return}const Ae=window.location.hash.replace(/^#/,"");g(Te=>Te&&Ae&&Wc(Te.path,Te.method)===Ae?Te:null)},de=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const le=ae.current,Ae=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Te=je=>{if(je.key==="Escape"){je.preventDefault(),M(!1);return}if(je.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];je.shiftKey&&document.activeElement===ze?(je.preventDefault(),Ve.focus()):!je.shiftKey&&document.activeElement===Ve&&(je.preventDefault(),ze.focus())};return document.addEventListener("keydown",Te),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Te),de?.focus()}},[L]);const re=()=>{J({key:o,preferences:ho(o)})},Se=F=>{J(de=>{const le=de.key===o?de.preferences:ho(o);return{key:o,preferences:{...le,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>we.current?.scrollTo({top:0,behavior:"auto"})),Be=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wc(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},lt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!bt;Ba(o,"sidebarCollapsed",F),Se({sidebarCollapsed:F})},ht=nf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ft===void 0?ht:nf(ft),Vn=F=>{Ba(o,"expand",F),re()},qn=F=>{n&&(Ba(o,"theme",F),re())},kt=F=>{Ba(o,"expandedTags",F),Se({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=B3($e,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=$e==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=$e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),ve=p.jsx(pk,{spec:t,onEndpointSelect:Be,theme:$e,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.logo?p.jsx(QM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(iM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${bt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":bt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!bt&&ve}),p.jsxs("main",{ref:we,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(O3,{spec:t,path:h.path,method:h.method,theme:$e,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:lt}):p.jsx(_3,{spec:t,onEndpointSelect:Be,theme:$e}),p.jsx(q3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:$e,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:ae,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${$e==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:ve})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${$e==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(tM,{open:B&&T,theme:$e,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:Be,messages:X}),p.jsx(X3,{spec:t,theme:$e,messages:X,onEndpointSelect:Be,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>lt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Z3,{open:G,theme:$e,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:ft,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function ZM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function eR(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function tR(t,e){const n=e.load||ZM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),o={},c=new Map;async function u(g){if(g===r)return s;if(o[g])return o[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return o[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=eR(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(o).length&&(s[dp]=o),s}async function nR(t,e){return tR(t,e)}const ru="1",su=new WeakMap;function iR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=iR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},o=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!o.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function rR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function sR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=su.get(t);n&&n.unmount();const r=$A.createRoot(t);return su.set(t,r),r.render(e),()=>{su.get(t)===r&&su.delete(t),r.unmount()}}function $1(t,e,n){return sR(n),B1(t,p.jsx(WM,{spec:fp(e,n),theme:rR(n),options:n}))}function I1(t,e){const n={contractVersion:ru,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:ru,...e.options||{}},r=e.baseUri?await nR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:ru}),As.FLEXDOC_CONTRACT_VERSION=ru,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/ruby/assets/flexdoc.standalone.js b/adapters/ruby/assets/flexdoc.standalone.js index 3efc5433..bf78a4d9 100644 --- a/adapters/ruby/assets/flexdoc.standalone.js +++ b/adapters/ruby/assets/flexdoc.standalone.js @@ -1,86 +1,86 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(q,J){var oe=q.length;q.push(J);e:for(;0>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1>>1,we=q[he];if(0>>1;hes(me,ae))nes(Ce,me)?(q[he]=Ce,q[ne]=ae,he=ne):(q[he]=me,q[z]=ae,he=z);else if(nes(Ce,ae))q[he]=Ce,q[ne]=ae,he=ne;else break e}}return J}function s(q,J){var ae=q.sortIndex-J.sortIndex;return ae!==0?ae:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var we=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof we=="function"){b.callback=we,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=ae,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=ae,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,ae-he))):(q.sortIndex=we,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var ae=v;v=J;try{return q.apply(this,arguments)}finally{v=ae}}}})(vd)),vd}var Ng;function RA(){return Ng||(Ng=1,xd.exports=MA()),xd.exports}var wd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function($e){return $e})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ad.exports=_A(),Ad.exports}var Mg;function qA(){if(Mg)return oo;Mg=1;var t=RA(),e=Sd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1we||(i.current=he[we],he[we]=null,we--)}function me(i,l){we++,he[we]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function $e(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,a=Q2(l,i.type);l!==a&&(me(Ce,i),me(ne,a))}function ft(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oa._currentValue=ae)}var At,bt;function Ge(i){if(At===void 0)try{throw Error()}catch(a){var l=a.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",bt=-1)":-1m||$[d]!==te[m]){var fe=` -`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ge(a):""}function Se(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",a=null;do l+=Se(i,a),a=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var $e=Object.prototype.hasOwnProperty,We=t.unstable_scheduleCallback,vt=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ft=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,kt=t.unstable_NormalPriority,x=t.unstable_LowPriority,U=t.unstable_IdlePriority,pe=t.log,ue=t.unstable_setDisableYieldValue,X=null,k=null;function V(i){if(typeof pe=="function"&&ue(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var W=Math.clz32?Math.clz32:de,we=Math.log,F=Math.LN2;function de(i){return i>>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(ve(i)/F|0)|0}var le=256,Ae=262144,Te=4194304;function je(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,a){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=je(d):(S&=N,S!==0?m=je(S):a||(a=N&~i,a!==0&&(m=je(a))))):(N=d&~y,N!==0?m=je(N):S!==0?m=je(S):a||(a=d&~i,a!==0&&(m=je(a)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,a=l&-l,y>=a||y===32&&(a&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Te;return Te<<=1,(Te&62914560)===0&&(Te=4194304),i}function Fn(i){for(var l=[],a=0;31>a;a++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Fo(i,l,a,d,m,y){var S=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(a=S&~a;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var oR=/[\n"\\]/g;function vi(i){return i.replace(oR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,a,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):a!=null?gp(i,S,On(a)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,a,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}a=a!=null?""+On(a):"",l=l!=null?""+On(l):a,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,a){l==="number"&&ou(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Tl(i,l,a,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Go={};Object.defineProperty(Go,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Go,Go),window.removeEventListener("test",Go,Go)}catch{wp=!1}var es=null,Sp=null,cu=null;function Q1(){if(cu)return cu;var i,l=Sp,a=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Qo),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return LR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function BR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function $R(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),cu=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:a,offset:l-i};i=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=pw(a)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=ou(i.document);l instanceof i.HTMLIFrameElement;){try{var a=typeof l.contentWindow.location.href=="string"}catch{a=!1}if(a)i=l.contentWindow;else break;l=ou(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var YR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,ta=null,Rp=!1;function bw(i,l,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Rp||Rl==null||Rl!==ou(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),ta&&ea(ta,d)||(ta=d,d=nd(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|a<it?(dt=Ie,Ie=null):dt=Ie.sibling;var vt=ie(P,Ie,Z[it],ye);if(vt===null){Ie===null&&(Ie=dt);break}i&&Ie&&vt.alternate===null&&l(P,Ie),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt,Ie=dt}if(it===Z.length)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;itit?(dt=Ie,Ie=null):dt=Ie.sibling;var Ss=ie(P,Ie,vt.value,ye);if(Ss===null){Ie===null&&(Ie=dt);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),xt===null?Fe=Ss:xt.sibling=Ss,xt=Ss,Ie=dt}if(vt.done)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;!vt.done;it++,vt=Z.next())vt=xe(P,vt.value,ye),vt!==null&&(H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return pt&&gr(P,it),Fe}for(Ie=d(Ie);!vt.done;it++,vt=Z.next())vt=oe(Ie,P,it,vt.value,ye),vt!==null&&(i&&vt.alternate!==null&&Ie.delete(vt.key===null?it:vt.key),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return i&&Ie.forEach(function(fD){return l(P,fD)}),pt&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){a(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){a(P,H.sibling),ye=m(H,Z.props),oa(ye,Z),ye.return=P,P=ye;break e}a(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=xu(Z.type,Z.key,Z.props,null,P.mode,ye),oa(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){a(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{a(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,Nu(Z),ye);if(Z.$$typeof===j)return Et(P,H,Su(P,Z),ye);Tu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(a(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(a(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):a(P,H)}return function(P,H,Z,ye){try{la=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===ku)throw Ie;var xt=li(29,Ie,null,P.mode);return xt.lanes=ye,xt.return=P,xt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function os(i,l,a){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=bu(i),Cw(i,null,a),l}return yu(i,d,l,a),bu(i)}function aa(i,l,a){if(l=l.updateQueue,l!==null&&(l=l.shared,(a&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}function Zp(i,l){var a=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var m=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var S={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,a=a.next}while(a!==null);y===null?m=y=l:y=y.next=l}else m=y=l;a={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=l:i.next=l,a.lastBaseUpdate=l}var em=!1;function ca(){if(em){var i=zl;if(i!==null)throw i}}function ua(i,l,a,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,oe=ie!==N.lane;if(oe?(ut&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=a;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=m.callbacks,oe===null?m.callbacks=[ie]:oe.push(ie))}else oe={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=oe,$=xe):fe=fe.next=oe,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;oe=N,N=oe.next,oe.next=null,m.lastBaseUpdate=oe,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,a);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=t4($,d);ha(i,l,fe,di(i))}else ha(i,l,d,di(i))}catch(xe){ha(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function o4(){}function ym(i,l,a,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,ae,a===null?o4:function(){return AS(i),a(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ae},next:null};var a={};return l.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ha(i,l.next.queue,{},di())}function bm(){return yn(Oa)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function a4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var a=di();i=ls(a);var d=os(l,i,a);d!==null&&(Qn(d,l,a),aa(d,l,a)),l={cache:Kp()},i.payload=l;return}l=l.return}}function c4(i,l,a){var d=di();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bu(i)?TS(l,a):(a=qp(i,l,a,d),a!==null&&(Qn(a,i,d),jS(a,l,d)))}function NS(i,l,a){var d=di();ha(i,l,a,d)}function ha(i,l,a,d){var m={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,a);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return yu(i,l,m,0),Mt===null&&gu(),!1}catch{}if(a=qp(i,l,m,d),a!==null)return Qn(a,i,d),jS(a,l,d),!0}return!1}function xm(i,l,a,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Bu(i)){if(l)throw Error(r(479))}else l=qp(i,a,d,2),l!==null&&Qn(l,i,2)}function Bu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=Ou=!0;var a=i.pending;a===null?l.next=l:(l.next=a.next,a.next=l),i.pending=l}function jS(i,l,a){if((a&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}var pa={readContext:yn,use:Du,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};pa.useEffectEvent=zt;var ES={readContext:yn,use:Du,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,a){a=a!=null?a.concat([i]):null,Lu(4194308,4,gS.bind(null,l,i),a)},useLayoutEffect:function(i,l){return Lu(4194308,4,i,l)},useInsertionEffect:function(i,l){Lu(4,2,i,l)},useMemo:function(i,l){var a=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return a.memoizedState=[d,l],d},useReducer:function(i,l,a){var d=$n();if(a!==void 0){var m=a(l);if(Js){V(!0);try{a(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=c4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,a=NS.bind(null,nt,l);return l.dispatch=a,[i.memoizedState,a]},useDebugValue:mm,useDeferredValue:function(i,l){var a=$n();return gm(a,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,a){var d=nt,m=$n();if(pt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=l(),Mt===null)throw Error(r(349));(ut&127)!==0||Jw(d,l,a)}m.memoizedState=a;var y={value:a,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,a,l),null),a},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(pt){var a=Zi,d=Wi;a=(d&~(1<<32-W(d)-1)).toString(32)+a,l="_"+l+"R_"+a,a=Mu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,a),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,a=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,a)),i||is(l,!0)}else i=id(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(a=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),a!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else a=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return l.flags&256?(ai(l),l):(ai(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(ai(l),l):(ai(l),null)}return ai(l),(l.flags&128)!==0?(l.lanes=a,l):(a=d!==null,i=i!==null&&i.memoizedState!==null,a&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),a!==i&&a&&(l.child.flags|=8192),Uu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)ga(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Eu(i),y!==null){for(l.flags|=128,ga(d,!1),i=y.updateQueue,l.updateQueue=i,Uu(l,i),l.subtreeFlags=0,i=a,a=l.child;a!==null;)Nw(a,i),a=a.sibling;return me(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Ku&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304)}else{if(!m)if(i=Eu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Uu(l,i),ga(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Ku&&a!==536870912&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,a=Kt.current,me(Kt,m?a&1|2:a&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return ai(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(a&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),a=l.updateQueue,a!==null&&Uu(l,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==a&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),l.memoizedState.cache!==a&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function p4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ft(l),null;case 31:if(l.memoizedState!==null){if(ai(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(ai(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return ai(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:ft(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&ai(l);break;case 13:ai(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:ai(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function ya(i,l){try{var a=l.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var m=d.next;a=m;do{if((a.tag&i)===i){d=void 0;var y=a.create,S=a.inst;d=y(),S.destroy=d}a=a.next}while(a!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,a){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=a,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var a=i.stateNode;try{Fw(l,a)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,a){a.props=Qs(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(d){Nt(i,l,d)}}function ba(i,l){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof a=="function"?i.refCleanup=a(d):a.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var a=i.ref,d=i.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(m){Nt(i,l,m)}else a.current=null}function n2(i){var l=i.type,a=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,a){try{var d=i.stateNode;q4(d,i.type,a,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,l):(l=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,l.appendChild(i),a=a._reactRootContainer,a!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,a),i=i.sibling;i!==null;)qm(i,l,a),i=i.sibling}function Vu(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?a.insertBefore(i,l):a.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vu(i,l,a),i=i.sibling;i!==null;)Vu(i,l,a),i=i.sibling}function r2(i){var l=i.stateNode,a=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,a),l[_t]=i,l[Yt]=a}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,an=null;function m4(i,l){if(i=i.containerInfo,rg=ud,i=yw(i),Op(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var oe;xe!==a||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(oe=xe.firstChild)!==null;)ie=xe,xe=oe;for(;;){if(xe===i)break t;if(ie===a&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(oe=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=oe}a=N===-1||$===-1?null:{start:N,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(sg={focusedElem:i,selectionRange:a},ud=!1,an=l;an!==null;)if(l=an,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,an=i;else for(;an!==null;){switch(l=an,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a title"))),xn(y,d,a),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(a.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(oe.rangeCount!==1||oe.anchorNode!==P.node||oe.anchorOffset!==P.offset||oe.focusNode!==H.node||oe.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),oe.removeAllRanges(),Ye>Et?(oe.addRange(Z),oe.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),oe.addRange(Z))}}}}for(xe=[],oe=N;oe=oe.parentNode;)oe.nodeType===1&&xe.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Na?32:a,q.T=null,a=Fm,Fm=null;var y=ps,S=jr;if(ln=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,a),wt=N,ka(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,a){l=Si(a,l),l=Am(i.stateNode,l,2),i=os(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,a){if(i.tag===3)q2(i,i,a);else for(;l!==null;){if(l.tag===3){q2(l,i,a);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(a,i),a=BS(2),d=os(l,a,2),d!==null&&($S(a,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,a){var d=i.pingCache;if(d===null){d=i.pingCache=new b4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(a)||(Hm=!0,m.add(a),i=A4.bind(null,i,l,a),l.then(i,i))}function A4(i,l,a){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ut&a)===a&&(Ut===4||Ut===3&&(ut&62914560)===ut&&300>ht()-Yu?(wt&2)===0&&Zl(i,0):zm|=a,Ql===ut&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function k4(i){var l=i.memoizedState,a=0;l!==null&&(a=l.retryLane),B2(i,a)}function C4(i,l){var a=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(a=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,a)}function N4(i,l){return We(i,l)}var Zu=null,to=null,Xm=!1,ed=!1,Jm=!1,gs=0;function tr(i){i!==to&&i.next===null&&(to===null?Zu=to=i:to=to.next=i),ed=!0,Xm||(Xm=!0,j4())}function ka(i,l){if(!Jm&&ed){Jm=!0;do for(var a=!1,d=Zu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,z2(d,y))}else y=ut,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(a=!0,z2(d,y));d=d.next}while(a);Jm=!1}}function T4(){$2()}function $2(){ed=Xm=!1;var i=0;gs!==0&&$4()&&(i=gs);for(var l=ht(),a=null,d=Zu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,a===null?Zu=m:a.next=m,m===null&&(to=a)):(a=d,(i!==0||(y&3)!==0)&&(ed=!0)),d=m}ln!==0&&ln!==5||ka(i),gs!==0&&(gs=0)}function I2(i,l){for(var a=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function oA(i,l,a){var d=no;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof a=="string"&&(m+='[crossorigin="'+a+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:a,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function K4(i){Er.D(i),oA("dns-prefetch",i,null)}function G4(i,l){Er.C(i,l),oA("preconnect",i,l)}function X4(i,l,a){Er.L(i,l,a);var d=no;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&a&&a.imageSrcSet?(m+='[imagesrcset="'+vi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(m+='[imagesizes="'+vi(a.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=io(i);break;case"script":y=ro(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&a&&a.imageSrcSet?void 0:i,as:l},a),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(ja(y))||l==="script"&&d.querySelector(Ea(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function J4(i,l){Er.m(i,l);var a=no;if(a&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ro(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),a.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ea(y)))return}d=a.createElement("link"),xn(d,"link",i),Xt(d),a.head.appendChild(d)}}}function Q4(i,l,a){Er.S(i,l,a);var d=no;if(d&&i){var m=fr(d).hoistableStyles,y=io(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(ja(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},a),(a=ji.get(y))&&fg(i,a);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,sd(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function W4(i,l){Er.X(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Z4(i,l){Er.M(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function aA(i,l,a,d){var m=(m=Re.current)?rd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(l=io(a.href),a=fr(m).hoistableStyles,d=a.get(l),d||(d={type:"style",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=io(a.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(ja(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ji.set(i,a),y||eD(m,i,a,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=a.async,a=a.src,typeof a=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ro(a),a=fr(m).hoistableScripts,d=a.get(l),d||(d={type:"script",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function io(i){return'href="'+vi(i)+'"'}function ja(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function eD(i,l,a,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",a),Xt(l),i.head.appendChild(l))}function ro(i){return'[src="'+vi(i)+'"]'}function Ea(i){return"script[async]"+i}function uA(i,l,a){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(a.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),sd(d,a.precedence,i),l.instance=d;case"stylesheet":m=io(a.href);var y=i.querySelector(ja(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(a),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,sd(y,a.precedence,i),l.instance=y;case"script":return y=ro(a.src),(m=i.querySelector(Ea(y)))?(l.instance=m,Xt(m),m):(d=a,(m=ji.get(y))&&(d=b({},a),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,sd(d,a.precedence,i));return l.instance}function sd(i,l,a){for(var d=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function tD(i,l,a){if(a===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function nD(i,l,a,d){if(a.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var m=io(d.href),y=l.querySelector(ja(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=od.bind(i),l.then(i,i)),a.state.loading|=4,a.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),a.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,l),(l=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=od.bind(i),l.addEventListener("load",a),l.addEventListener("error",a))}}var pg=0;function iD(i,l){return i.stylesheets&&i.count===0&&cd(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function od(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ad=null;function cd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ad=new Map,l.forEach(rD,i),ad=null,od.call(i))}function rD(i,l){if(!(l.state.loading&4)){var a=ad.get(i);if(a)var d=a.get(null);else{a=new Map,ad.set(i,a);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),bd.exports=qA(),bd.exports}var $A=BA(),I=Sd();const kd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!o&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(o)?o:[o]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},o)=>I.createElement(VA,{ref:o,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _a=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Cd=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const ao=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Nd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Td=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const La=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const jd=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const Ed=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const co=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Od=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Md=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},qa={},Or={},Pg;function uo(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` -`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` -`,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` -`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentb&&(h=" ... ",o=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(o,c).replace(/\t/g,"→")+g,pos:u-o+h.length}}function n(s,o){return t.repeat(" ",o-s.length)+s}function r(s,o){if(o=Object.create(o||null),!s.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+o.linesAfter,f.length).toString().length,w=o.maxLength-(o.indent+v+3);for(let C=1;C<=o.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",o.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` +`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",o.indent)+n((s.line+1).toString(),v)+" | "+A.str+` +`,b+=t.repeat("-",o.indent+v+3+A.pos)+`^ +`;for(let C=1;C<=o.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",o.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Dd=r,Dd}var _d,Gg;function Mn(){if(Gg)return _d;Gg=1;const t=fo(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(o){const c={};return o!==null&&Object.keys(o).forEach(function(u){o[u].forEach(function(f){c[String(f)]=u})}),c}function s(o,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+o+'" YAML type.')}),this.options=c,this.tag=o,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return _d=s,_d}var Ld,Xg;function Jg(){if(Xg)return Ld;Xg=1;const t=fo(),e=Mn();function n(o,c){const u=[];return o[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(o.multi[u.kind].push(u),o.multi.fallback.push(u)):o[u.kind][u.tag]=o.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function o(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ud}var Vd,d0;function f0(){if(d0)return Vd;d0=1;const t=uo(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function o(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Vd=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:o,predicate:f,represent:u,defaultStyle:"lowercase"}),Vd}var Fd,h0;function p0(){return h0||(h0=1,Fd=r0().extend({implicit:[l0(),a0(),u0(),f0()]})),Fd}var Pd,m0;function g0(){return m0||(m0=1,Pd=p0()),Pd}var Yd,y0;function b0(){if(y0)return Yd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function o(c){return c.toISOString()}return Yd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:o}),Yd}var Kd,x0;function v0(){if(x0)return Kd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Kd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Kd}var Gd,w0;function S0(){if(w0)return Gd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function o(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Gd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:s}),Gd}var Xd,A0;function k0(){if(A0)return Xd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(o){if(o===null)return!0;const c={},u=o;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function ae(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function we(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function bt(x,U,pe){let ue,X,k,V,W,ve;const F=x.kind,de=x.result;let le=x.input.charCodeAt(x.position);if(R(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;le!==0;){if(le===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(le===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&ft(x)||pe&&_(le))break;if(O(le))if(V=x.line,W=x.lineStart,ve=x.lineIndent,$e(x,!1,-1),x.lineIndent>=U){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=ve;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))$e(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const ve=x.anchor;let F,de,le,Ae;const Te=Object.create(null);let je,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&ae(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if($e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=ve,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=je=ze=null,de=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=le=!0,x.position++,$e(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ht(x,U,o,!1,!0),Le=x.tag,je=x.result,$e(x,!0,U),Ve=x.input.charCodeAt(x.position),(le||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),$e(x,!0,U),ht(x,U,o,!1,!0),ze=x.result),Ae?He(x,W,Te,Le,je,ze,ue,X,k):de?W.push(He(x,null,Te,Le,je,ze,ue,X,k)):W.push(je),$e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function Se(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,ve=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` -`,de=we&&(k[k.length-2]===` +`,X?1+W:W),X=!0,k=!0,W=0;const le=x.position;for(;!O(de)&&de!==0;)de=x.input.charCodeAt(++x.position);Ce(x,le,x.position,!1)}return!0}function Ne(x,U){const pe=x.tag,ue=x.anchor,X=[];let k=!1;if(x.firstTabInLine!==-1)return!1;x.anchor!==null&&ae(x,x.anchor,X);let V=x.input.charCodeAt(x.position);for(;V!==0&&(x.firstTabInLine!==-1&&(x.position=x.firstTabInLine,q(x,"tab characters must not be used in indentation")),V===45);){const W=x.input.charCodeAt(x.position+1);if(!R(W))break;if(k=!0,x.position++,$e(x,!0,-1)&&x.lineIndent<=U){X.push(null),V=x.input.charCodeAt(x.position);continue}const ve=x.line;if(ht(x,U,u,!1,!0),X.push(x.result),$e(x,!0,-1),V=x.input.charCodeAt(x.position),(x.line===ve||x.lineIndent>U)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(je&&(X=x.line,k=x.lineStart,V=x.position),ht(x,U,f,!0,ue)&&(je?Ae=x.result:Te=x.result),je||(He(x,F,de,le,Ae,Te,X,k,V),le=Ae=Te=null),$e(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const je=k=V=f===pe||u===pe;if(ue&&$e(x,!0,-1)&&(ve=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&le.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&ae(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&($e(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if($e(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,$e(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),$e(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ft(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,$e(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==o||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==o&&k!==f&&k!==u}function He(k,V,W){const ve=qe(k),F=ve&&!Ce(k);return(W?ve:ve&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==o&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function $e(k){return!Ce(k)&&k!==j}function ft(k,V){const W=k.charCodeAt(V);let ve;return W>=55296&&W<=56319&&V+1=56320&&ve<=57343)?(W-55296)*1024+ve-56320+65536:W}function At(k){return/^\n* /.test(k)}const bt=1,Ge=2,Q=3,re=4,Se=5;function Ne(k,V,W,ve,F,de,le,Ae){let Te,je=0,Le=null,ze=!1,Ve=!1;const Dt=ve!==-1;let Fn=-1,jn=Je(ft(k,0))&&$e(ft(k,k.length-1));if(V||le)for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}else{for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),je===u)ze=!0,Dt&&(Ve=Ve||Te-Fn-1>ve&&k[Fn+1]!==" ",Fn=Te);else if(!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}Ve=Ve||Dt&&Te-Fn-1>ve&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!F(k)?bt:de===we?Se:Ge:W>9&&At(k)?Se:le?de===we?Se:Ge:Ve?re:Q}function Be(k,V,W,ve,F){k.dump=(function(){if(V.length===0)return k.quotingType===we?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===we?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=ve||k.flowLevel>-1&&W>=k.flowLevel;function Te(je){return ne(k,je)}switch(Ne(V,Ae,k.indent,le,Te,k.quotingType,k.forceQuotes&&!ve,F)){case bt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+lt(z(V,de));case re:return">"+We(V,k.indent)+lt(z(ti(V,le),de));case Se:return'"'+ht(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",ve=k[k.length-1]===` +`,de=ve&&(k[k.length-2]===` `||k===` -`)?"+":we?"":"-";return W+de+` -`}function vt(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`)?"+":ve?"":"-";return W+de+` +`}function lt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let ve=(function(){let Ae=k.indexOf(` `);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` -`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` -`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` -`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` -`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` -`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ -`)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); -const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` -`)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` -`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`||k[0]===" ",de,le;for(;le=W.exec(k);){const Ae=le[1],Te=le[2];de=Te[0]===" ",ve+=Ae+(!F&&!de&&Te!==""?` +`:"")+Tn(Te,V),F=de}return ve}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let ve,F=0,de,le=0,Ae=0,Te="";for(;ve=W.exec(k);)Ae=ve.index,Ae-F>V&&(de=le>F?le:Ae,Te+=` +`+k.slice(F,de),F=de+1),le=Ae;return Te+=` +`,k.length-F>V&&le>F?Te+=k.slice(F,le)+` +`+k.slice(le+1):Te+=k.slice(F),Te.slice(1)}function ht(k){let V="",W=0;for(let ve=0;ve=65536?ve+=2:ve++){W=ft(k,ve);const F=ce[W];!F&&Re(W)?(V+=k[ve],W>=65536&&(V+=k[ve+1])):V+=F||ae(W)}return V}function ni(k,V,W){let ve="";const F=k.tag;for(let de=0,le=W.length;de"u"&&U(k,V,null,!1,!1))&&(ve!==""&&(ve+=","+(k.condenseFlow?"":" ")),ve+=k.dump)}k.tag=F,k.dump="["+ve+"]"}function Vn(k,V,W,ve){let F="";const de=k.tag;for(let le=0,Ae=W.length;le"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!ve||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let ve="";const F=k.tag,de=Object.keys(W);for(let le=0,Ae=de.length;le1024&&(Te+="? "),Te+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Te+=k.dump,ve+=Te))}k.tag=F,k.dump="{"+ve+"}"}function kt(k,V,W,ve){let F="";const de=k.tag,le=Object.keys(W);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Te=le.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?je+="?":je+="? "),je+=k.dump,Ve&&(je+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?je+=":":je+=": ",je+=k.dump,F+=je)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const ve=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=ve.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Te}return!0}}return!1}function U(k,V,W,ve,F,de,le){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Te=ve;ve&&(ve=k.flowLevel<0||k.flowLevel>V);const je=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(je&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(je&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")ve&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")ve&&k.dump.length!==0?(k.noArrayIndent&&!le&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&Be(k,k.dump,V,de,Te);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],ve=[];ue(k,W,ve);const F=ve.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const o of r){if(s===null||typeof s!="object"||!(o in s))throw new Error(`Reference not found: ${n}`);s=s[o]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const o=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return o[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:o,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),o?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],tf={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(tf),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function nf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...tf[t]]:Cs.filter(n=>t.some(r=>r===n||tf[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function ho(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(o=>typeof o=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function Ba(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const o={...ho(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete o[e]:o[e]=c,o.expand===void 0&&o.sidebarCollapsed===void 0&&o.theme===void 0&&o.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(o))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],o=e[r]??s?.default;if(o===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(o))throw new Error(`Invalid value for server variable ${r}: ${o}`);return o})}function rf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const o=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of o)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return rf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=rf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const o=r.requestBody,c=o?Object.keys(o.content||{})[0]:void 0;if(c){s.contentType=c;const u=o.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function sf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=sf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,o])=>`${s}=${cn(o)}`).join(","):r.flatMap(([s,o])=>[s,cn(o)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=sf(e),o=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(o);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[o(f),o(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=o(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=sf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([o,c])=>[`${t.name}[${o}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(o=>[t.name,cn(o)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const o=Object.entries(s);return r?o.map(([c,u])=>[c,cn(u)]):[[t.name,o.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,o){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,o))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=o[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=rf(t,e,n),o=s.servers[0],c=r.serverUrl||(o?wk(o,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const o=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)o.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&o.push(` --data-raw ${un(t.body)}`),o.join(` \\ +`)}if(e==="javascript"){const o={method:t.method};return n.length&&(o.headers=t.headers),t.body&&(o.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(o,null,2)}); +const data = await response.json();`}if(e==="python"){const o=["import requests","",`url = ${un(t.url)}`];return n.length&&o.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&o.push(`body = ${un(t.body)}`),o.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),o.join(` +`)}if(e==="go"){const o=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${o})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` +`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[o,c]of n)r.push(` .header(${un(o)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var lf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,o=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=ae.value.length,ae=ae.next){var we=ae.value;if(j.length>O.length)return;if(!(we instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=ae.value.length;Re>=ne;)ae=ae.next,ne+=ae.value.length;if(ne-=ae.value.length,he=ne,ae.value instanceof f)continue;for(var Ce=ae;Ce!==j.tail&&(neM.reach&&(M.reach=$e);var ft=ae.prev;He&&(ft=v(j,ft,He),he+=He.length),w(j,ft,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(ae=v(j,ft,At),Je&&v(j,ae,Je),T>1){var bt={cause:G+","+B,reach:$e};g(O,j,R,ae.prev,he,bt),M&&bt.reach>M.reach&&(M.reach=bt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+o+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(o),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:o=!1})=>{const[c,u]=kd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${o?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:o=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(o.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(o);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:o})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:o},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:o})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:o})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function $a(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),o=Object.keys(r);return s.length===o.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function of(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const o=e(),c=of(o,r),u={key:r,value:String(s),enabled:!0};c>=0?o[c]=u:o.push(u)};return{get(r){const s=of(e(),r);return s>=0?e()[s].value:void 0},has(r){return of(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=$a(t.variables||{}),r=$a(t.collectionVariables||{}),s=$a(t.externalVariables||{}),o=$a(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(o,R)?n[R]=o[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return o[R]},has(R){return Object.prototype.hasOwnProperty.call(o,R)},set(R,_){const L=String(_);o[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete o[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(o,M)?o[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` -`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!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:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,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}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{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 n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.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 fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(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(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(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}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(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,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}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 n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` -`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;se.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",o=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${o}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const o=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>o.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:o}}function cf(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function Ia(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&Ia(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&Ia(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&Ia(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&Ia(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const o=Y0(n);if(o.length>0)throw new Error(`This request requires API host execution (${o.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=cf(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,o])=>({key:s,value:o})),body:t.body,contentType:cf(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:cf(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,o])=>({key:s,value:o,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function po(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const o=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return o&&!("$ref"in o)?o:void 0}function lC(t,e,n,r){const o=rC(t,e,n)?.security??t.security??[];if(!o.length)return;const c=o.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=o.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(o.find(f=>Object.keys(f).length===0)??o[0])}function oC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,o=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:o?.authorizationUrl,tokenUrl:o?.tokenUrl,scopes:n.length?n:Object.keys(o?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function aC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let o=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return o;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return o;if(!h)return{...o,auth:{type:"inherit"}};const g=oC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?o=X0(o,"Authorization"):g.type==="apiKey"&&g.in==="header"?o=X0(o,g.key):g.type==="apiKey"&&g.in==="query"&&(o=aC(o,g.key)),{...o,auth:g}):o}function uC(t,e,n,r,s){const o=B0(t,e,n,r);return{request:cC(t,e,n,r,o),serverUrl:r.serverUrl||s}}function Ha(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const uf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function df(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>df(e.key)?{...e,value:uf}:e)}function fC(t){return t?.map(e=>df(e[0])?[e[0],uf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const o=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return df(g)?`${h}=${encodeURIComponent(uf)}`:u}).join("&");return`${o}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Ha(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",o={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete o.responseBody,delete o.responseBodyTruncated,delete o.requestBodyTruncated),o});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Ha(n.auth)})),folders:t.folders.map(n=>({...n,auth:Ha(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Ha(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function mo(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function za(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function Ua(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!Ua(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Va(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function ff(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(ff(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Va(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(ff(t),JSON.stringify(wC(e))):sessionStorage.removeItem(ff(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(Ua))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(Ua))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(Ua))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Va(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Va(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Va(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const o=r.get(s.parentFolderId);(!o||o.collectionId!==s.collectionId||o.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const o=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(o.has(c)){s.parentFolderId=void 0;break}o.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!za(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!za(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!za(t,"runIndex")||!za(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,o])=>[s,o]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=mo();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function oy(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),o=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:o,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:o,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=o=>{if(o.length<=e)return e-=o.length,o;const c=o.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(o=>({...o,value:r(o.value)}))),s.formData&&(s.formData=s.formData.map(o=>({...o,value:r(o.value)}))),{request:s,truncated:n}}function ay(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),o={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:mo()};return{...t,history:[o,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),o=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!o.has(c.id);){if(o.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function hf(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function pf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),o=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,o=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});o=!0}if(!o)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:mo()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let o=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=o.filter(w=>w.key.trim()!==h);v.length!==o.length&&(o=v,c=!0);continue}const g=o.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];o[v]={...o[v],key:h,value:b,enabled:!0},g.length>1&&(o=o.filter((w,A)=>A===v||w.key.trim()!==h))}else o.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:o,updatedAt:mo()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=mo();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const o=e.transaction(tl,"readonly").objectStore(tl).get(t);o.onsuccess=()=>n(AC(t,oy(o.result))),o.onerror=()=>r(o.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const o=n.transaction(tl,"readwrite");o.objectStore(tl).put(Z0(e),t),o.oncomplete=()=>r(),o.onerror=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace")),o.onabort=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),o=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{o.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,o.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function mf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,o=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:mf(O,.5),p95Ms:mf(O,.95),p99Ms:mf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),o=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:o===null?null:new Date(o).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,o=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const gf=zC();function VC(t){gf.record(t)}function FC(){return gf.snapshot()}function PC(){gf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function yf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=yf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Fa(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,o]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${o}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Pa(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&po(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,o=t.hostExecution?.preferHostExecution,c=o===!1?!1:t.preferHostExecution??s??o??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Pa({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:o}of n){const c=s.file;r.append(`formData[${o}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=yf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let o=yf(t.request),c=Fa(t.variables),u=Fa(t.collectionVariables);const f=Fa(t.externalVariables);let h=Fa(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(o=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(o={...o,auth:t.resolveAuth(o.auth)}),o=nC(o,c),w=(o.method||"GET").toUpperCase(),A=o.url;const[j,,,R]=Pa({request:o,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(o);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(o);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function bf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:o="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":o,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Ya(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const o of e)n+=String.fromCharCode(o);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function oN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),o=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",o),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Ya(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function aN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||aN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const o=vy(48),c=await oN(o);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:o}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,o=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:o,scope:typeof n.scope=="string"?n.scope:void 0}}async function Ka(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},o=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&o?s.Authorization=`Basic ${lN(`${o}:${t.clientSecret||""}`)}`:(o&&e.set("client_id",o),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),o=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-osetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}const s=await cN(t,e.windowObject),o=await dN(s,e);if((o.searchParams.get("state")||new URLSearchParams(o.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(o.hash.replace(/^#/,"")),f=o.searchParams.get("error")||u.get("error");if(f){const b=o.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=o.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Ka(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Ya(t);return s&&r.set("scope",s),Ka(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,o]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{o(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{o(!1)}},w=async()=>{o(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{o(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},xf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:o,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>o(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>o({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:o}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>o({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>o({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>o({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>o({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>o({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>o({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>o({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>o({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>o({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>o({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>o({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>o({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>o({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>o({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>o({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>o({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>o({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>o({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let vf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=wf(t,e);for(e+=jy(r);e=0&&Ay(wf(t,c));)o++,c-=2;if(o%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new go(this),o=new go(e);for(let c=n,u=n;;){if(s.next(c),o.next(c),c=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new go(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.text[o],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let o=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ga(o.text,c.text.slice(),0,o.length);if(u.length<=32)r.push(new Vt(u,c.length+o.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ga(this.text,Ga(r.text,Ey(this.text,0,e)),n),o=this.length+r.length-(n-e);return s.length<=32?new Vt(s,o):Hi.from(Vt.split(s,[]),o)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;o<=n&&ce&&c&&(s+=r),eo&&(s+=u.slice(Math.max(0,e-o),n-o)),o=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let o of e)r.push(o),s+=o.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.children[o],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let o=0,c=0;c<=n&&o=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=o&&n<=u){let f=c.replace(e-o,n-o,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;oe&&o&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,o,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,o+=n){if(s==c||o==u)return r;let f=this.children[s],h=e.children[o];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),o=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>o&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ga(t,e,n=0,r=1e9){for(let s=0,o=0,c=!0;o=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],o=this.offsets[r],c=o>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new go(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},go.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const Sf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return o+(e-s);o+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?o:o+f;o+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Af(this,(n,r,s,o,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return kf(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,o=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,o.text),o.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],o=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||Sf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(o,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,o,g,b),s=h,o=g}}}function kf(t,e,n,r=!1){let s=[],o=r?[]:null,c=new yo(t),u=new yo(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),o.forward2(f),c.forward(f)}}}}class yo{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-o.from),n=e.indexOf(r);for(let s=1;so.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Cf=0;class Ue{constructor(e,n,r,s,o){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=Cf++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Nf),!!e.static,e.enables)}of(e){return new Xa([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Nf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Xa{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=Cf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,o=this.id,c=e[o]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Tf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[o];if(A!=null){let C=Za(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),o=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Ja).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let o=r.values[n],c=this.updateF(o,s);return this.compareF(o,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let o=r.facet(Ja),c=s.facet(Ja),u;return(u=o.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Ja.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function bo(t){return e=>new Ly(e,t)}const Qa={highest:bo(Ns.highest),high:bo(Ns.high),default:bo(Ns.default),low:bo(Ns.low),lowest:bo(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new jf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Wa{constructor(e,n,r,s,o,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=o,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],o=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(o[v.facet.id]||(o[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in o){let w=o[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Nf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Wa(e,c,b,u,f,o)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function o(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof jf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)o(h,u);else if(c instanceof jf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),o(h,u)}else if(c instanceof Ly)o(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&o(c.provides,u);else if(c instanceof Xa)r[u].push(c),c.facet.extensions&&o(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(h,u)}}return o(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function xo(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Za(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),Ef=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let o=s.map(n);o&&r.push(o)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,o,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=o,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),o.some(u=>u.type==rn.time)||(this.annotations=o.concat(rn.time.of(Date.now())))}static create(e,n,r,s,o,c){return new rn(e,n,r,s,o,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let o,c;if(r=t[r]))o=t[r++],c=t[r++];else if(s=0;s--){let o=r[s](t);o instanceof rn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof rn?t=o[0]:t=Vy(e,sl(o),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let o=n[s](t);o&&Object.keys(o).length&&(r=Uy(r,Of(e,o,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Mf;try{Mf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Mf)return Mf.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,o,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let o;n?o=e.startState.values.slice():(n=Wa.resolve(r,s,this),o=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(Ef)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),o=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Wa.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||Sf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(Ef)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(o,c)=>c.create(o),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>n.length?r:n[o-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let o of this.facet(qy))for(let c of o(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(o(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Rf(t,e,n={}){let r={};for(let s of t)for(let o of Object.keys(s)){let c=s[o],u=r[o];if(u===void 0)r[o]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,o))r[o]=n[o](u,c);else throw new Error("Config merge conflict for field "+o)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return _f.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Df(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let _f=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function Lf(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class qf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let o=r?this.to:this.from;for(let c=s,u=o.length;;){if(c==u)return c;let f=c+u>>1,h=o[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let o=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,o);oE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}o(C,E,v)}}return{mapped:c.length?new qf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:o=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(Lf)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new vo;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new vo),o.addRange(f,h,g,!1)};for(let f=0;f=o&&e<=o+c.length&&c.between(o,e-o,n-o,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return wo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return wo.from(e).goto(n)}static compare(e,n,r,s,o=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),f=Fy(c,u,r),h=new So(c,f,o),g=new So(u,f,o);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let o=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(o.length!=c.length)return!1;if(!o.length)return!0;let u=Fy(o,c),f=new So(o,u,0).goto(r),h=new So(c,u,0).goto(r);for(;;){if(f.to!=h.to||!$f(f.active,h.active)||f.point&&(!h.point||!Df(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,o=-1){let c=new So(e,null,o).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new vo;for(let s of e instanceof _f?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(Lf);e=r}return t}mt.empty.nextLayer=mt.empty;class vo{finishChunk(e){this.chunks.push(new qf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new vo)).addRange(e,n,r,s)}addInner(e,n,r,s){let o=e-this.lastTo||r.startSide-this.last.endSide;if(s&&o<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let o of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,o));return s.length==1?s[0]:new wo(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),Bf(this.heap,0)}}}function Bf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class So{constructor(e,n,r){this.minPoint=r,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=wo.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){ec(this.active,e),ec(this.activeTo,e),ec(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:o}=this.cursor;for(;n0;)n++;tc(this.active,n,r),tc(this.activeTo,n,s),tc(this.activeRank,n,o),e&&tc(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&ec(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,o){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!o.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Df(t.point,n.point)&&$f(t.activeForPoint(t.to),n.activeForPoint(n.to))||o.comparePoint(u,A,t.point,n.point),g=!1):(g&&o.boundChange(u),A>u&&!$f(t.active,n.active)&&o.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function $f(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;o+=t.charCodeAt(s)==9?n-o%n:1,s=kn(t,s)}return t.length}const If="ͼ",Gy=typeof Symbol>"u"?"__"+If:Symbol.for(If),Hf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ol{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function o(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))o(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");o(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)o(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,If+e.toString(36)}static mount(e,n,r){let s=e[Hf],o=r&&r.nonce;s?o&&s.setNonce(o):s=new IN(e,o),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let o=Jy.get(r);if(o)return e[Hf]=o;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Hf]=this}mount(e,n){let r=this.sheet,s=0,o=0;for(let c=0;c-1&&(this.modules.splice(f,1),o--,f=-1),f==-1){if(this.modules.splice(o++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Ao[dn]=String.fromCharCode(dn);for(var zf in $r)Ao.hasOwnProperty(zf)||(Ao[zf]=$r[zf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ao:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Uf=typeof document<"u"?document:{documentElement:{style:{}}};const Vf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Ff=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),ic=!!(Qy||Ff||Vf),Wy=!ic&&/gecko\/(\d+)/i.test(Dn.userAgent),Pf=!ic&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in Uf.documentElement.style,Yf=!ic&&/Apple Computer/.test(Dn.vendor),eb=Yf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:ic,ie_version:Qy?Uf.documentMode||6:Ff?+Ff[1]:Vf?+Vf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Pf,chrome_version:Pf?+Pf[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Yf,safari_version:Yf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:Uf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Kf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const rc=Object.create(null);function Gf(t,e,n){if(t==e)return!0;t||(t=rc),e||(e=rc);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let o of r)if(o!=n&&(s.indexOf(o)==-1||t[o]!==e[o]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:o,end:c}=nb(e,n);r=(o?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new Co(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}on.none=mt.empty;class ko extends on{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Kf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||rc}eq(e){return this==e||e instanceof ko&&this.tagName==e.tagName&&Gf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}ko.prototype.point=!1;class Co extends on{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Co&&this.spec.class==e.spec.class&&Gf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Co.prototype.mapMode=Wn.TrackBefore,Co.prototype.point=!0;class js extends on{constructor(e,n,r,s,o,c){super(n,r,o,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function al(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class No extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof No&&this.tagName==e.tagName&&Gf(this.attributes,e.attributes)}static create(e){return new No(e.tagName,e.attributes||rc,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}No.prototype.startSide=No.prototype.endSide=-1;function To(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Xf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function jo(t,e){if(!e.anchorNode)return!1;try{return Xf(t,e.anchorNode)}catch{return!1}}function lc(t){return t.nodeType==3?Oo(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Eo(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function oc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,o,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+o)):e.right>v.right-o&&(E=e.right-v.right+o,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let o=t.parentNode;o&&!(o==n.body||(!e||r)&&s);)if(o.nodeType==1)!s&&o.scrollHeight>o.clientHeight&&(s=o),e&&!r&&o.scrollWidth>o.clientWidth&&(r=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:r,y:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ob(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ab(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ob(e))}let cb;function Oo(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),o.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!oc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(o<0||(s!=0?s<0?u.fromn:e[o].level>u.level))&&(o=c)}}if(o<0)throw new RangeError("Index out of range");return o}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?o:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,o=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else o=h,f++}}}function Wf(t,e,n,r,s,o,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Zf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Wf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>o[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==o[h-1].to){if(b)break e;let C=o[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&o[D-1].to==E)E=o[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Zf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var o;let c=r.head-t.from,u=Vi.find(e,c,(o=r.bidiLevel)!==null&&o!==void 0?o:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,o,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=o,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const cc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(uc.of(h=>{let g=h.plugin(u);return g?c(g):on.none})),o&&f.push(o(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class ih{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),rh=Ue.define(),uc=Ue.define(),Eb=Ue.define(),sh=Ue.define(),Mo=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(o=>o instanceof Function?o(t):o),s=[];return mt.spans(r,e.from,e.to,{point(){},span(o,c,u,f){let h=o-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let o of t.state.facet(Rb)){let c=o(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ro=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(o,c,u,f))),this.changedRanges=s}static create(e,n,r){return new dc(e,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}}const oT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return oT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 hc)return e;return null}static get(e){return e.cmTile}}class fc extends Ht{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 n=this.dom,r=null,s,o=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,o&&s!=u.dom&&(o.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,o&&s&&(o.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hc extends fc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,o=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&o++,s=n.pop()}else{let c=r.children[s++];if(c instanceof or)n.push(s),r=c,s=0;else{let u=o+c.length,f=e(c,o);if(f!==void 0)return f;o=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,o,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,c=e-f)}}),!r&&!o)throw new Error("No tile at position "+e);return r&&n<0||!o?{tile:r,offset:s}:{tile:o,offset:c}}}class or extends fc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new or(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends fc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,o=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,o=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?o:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):aT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:o}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,o)):s.domPosFor(o,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function aT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=lc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let o=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(o--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let o=this.dom.getClientRects(),c=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;c=o[f],!(e>0?f==0:f==o.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:o,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(o==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:o}=u.pop(),o++}else{let f=s.children[o],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(lh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(lh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let o=Ht.get(e.text);o&&this.cache.reused.set(o,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let o=this.ensureMarks(n,r);!s&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let o=e.length-1;o>=0;o--){let c=e[o],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(oh,0,32)||new Rs(oh.toDOM(),0,oh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(o),n=o}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(pc,void 0,1);return r&&(r.flags=n),r||new pc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:o,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return o?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const mc=[Rs,fl,Ms,Hn,pc,or,hc];for(let t=0;t[]),this.index=mc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,o=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,o=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,o+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=o=0):c instanceof Hn&&(s.shift(),o=Math.min(o,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,o=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>o),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let o=Ht.get(s);if(s==this.view.contentDOM)break;o instanceof Hn?n.push(o):o?.isLine()?r=o:o instanceof or||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new ko({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Kf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function lh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends sc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const oh=new class extends sc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=on.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 hc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let o=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Oe.ie||Oe.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),o&&!r.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(r=o.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 o=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||r.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&jo(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(o||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!Eo(h.node,h.offset,b.anchorNode,b.anchorOffset)||!Eo(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=To(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=To(e.root),{anchorNode:s,anchorOffset:o}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,o)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let o;if(e==r.dom)o=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?o=e:o=e.nextSibling}if(o==r.dom.firstChild)return s;for(;o&&!Ht.get(o);)o=o.nextSibling;if(!o)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,o=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(o=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,o=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(o&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:o}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof ch?null:s.coordsInWidget(o,n,!0):s.coordsIn(o,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(o,c){if(o.isComposite())for(let u of o.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(o.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof or)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?lc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=o,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=lc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,o;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=lc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,o=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:o}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let o=s==n.viewports.length?null:n.viewports[s],c=o?o.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(on.replace({widget:new ch(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!o)break;r=o.to+1}return on.set(e)}updateDeco(){let e=1,n=this.view.state.facet(uc).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),r=!1,s=this.view.state.facet(sh).map((o,c)=>{let u=typeof o=="function";return u&&(r=!0),u?o(this.view):o});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Db(this.view),c={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),o=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=r,!o)return null;let c=e-o.offset;return{from:c,to:c+o.node.nodeValue.length,node:o.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:o,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(o),f.mapPos(c),o,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class ch extends sc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(s.length==0)return ke.cursor(e);o==0?n=1:o==s.length&&(n=-1);let c=o,u=o;n<0?c=kn(s.text,o,!1):u=kn(s.text,o);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);o+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,o,t.state.tabSize)}function uh(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let o of r.type){if(o.from>e)break;if(!(o.toe)return o;(!s||o.type==fn.Text&&(s.type!=o.type||(n<0?o.frome)))&&(s=o)}}return s||r}return r}function OT(t,e,n,r){let s=uh(t,e.head,e.assoc||-1),o=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(o){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(o.top+o.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,o,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),o=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return o=>{let c=r(o);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,o=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=o<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(o<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*o,E=fh(t,{x:b,y:C},!1,o);if(n?C>f.bottom:Cu:O{if(e>o&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+o:v.bottom>=f+o))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=o&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let o=0;o{let c=r[o]-n,u=r[o+1]-n;return Oo(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Oo(f.dom,0,f.length)).getClientRects()}),o=e.children[s.i],c=r[s.i];return o.isText()?this.scanText(o,c):o.isComposite()?this.scanTile(o,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let o=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:oc(s))||oc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>o)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,c=1,u;if(this.lineSeparator?(o=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(o=u.index,c=u[0].length),this.append(n.slice(r,o<0?n.length:o)),o<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=o+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:o,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=o||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!Xf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Xf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,o=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,o=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:o,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,o=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=o.from,g=null;(c===8||Oe.android&&e.text.length=u&&o.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&b.slice(o.to-u)==e.text.slice(v=e.text.length-(b.length-(o.to-u)))?n={from:o.from,to:o.to,insert:gt.of(e.text.slice(o.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||gc(r,o))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(o.from).toDate.now()-50?n={from:o.from,to:o.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:o.from,to:o.to,insert:gt.of([" "])}),n)return hh(t,n,r,c);if(r&&!gc(r,o)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Mo).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function hh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,o,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,o=s.selection.main,c=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=o.frome.to?s.sliceDoc(e.to,o.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(o.head);let w=o.to-e.to;r=s.changeByRange(A=>{if(A.from==o.from&&A.to==o.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-o.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),o=0;for(;o0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,o-Math.min(c,u));n-=c+f-o}if(c=c?o-n:0;o-=f,u=o+(u-c),c=o}else if(u=u?o-n:0;o-=f,c=o+(c-u),u=o}return{from:o,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||o!=r)&&e.push(new zb(s,o))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function gc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let o in n)if(o!="scroll"){let c=!n[o].handlers.length,u=r[o];u&&c!=!u.handlers.length&&(s.removeEventListener(o,this.handleEvent),u=null),u||s.addEventListener(o,this.handleEvent,{passive:c})}for(let o in r)o!="scroll"&&!n[o]&&s.removeEventListener(o,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,o=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],yc=6;function bc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Mo).map(c=>c(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,o=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+yc?n=-bc(s-e.clientX):e.clientX+f.right>=c-yc&&(n=bc(e.clientX-c)),e.clientY-f.top<=o+yc?r=-bc(o-e.clientY):e.clientY+f.bottom>=u-yc&&(r=bc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=To(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function xc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=xc(t.state,th,e);let{state:n}=t,r,s=1,o=n.toText(e),c=o.lines==n.selection.ranges.length;if(ph!=null&&n.selection.ranges.every(f=>f.empty)&&ph==o.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?o.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=o.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(o);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ab(t.contentDOM);let o=t.root.activeElement;o&&!o.contains(t.contentDOM)&&o.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),o=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:o.from,u=s?s.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(o){o.docChanged&&(n.pos=o.changes.mapPos(n.pos),s=s.map(o.changes))},get(o,c,u){let f=t.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let o=s.posAtStart,c=o+s.length;(o>=n.to||c<=n.from)&&(n=ke.undirectionalRange(o,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",xc(t.state,nh,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=xc(t.state,th,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,c=r&&o&>(t,e)?{from:o.from,to:o.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,o=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),o()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let c=t.doc.lineAt(o);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:xc(t,nh,e.join(t.lineBreak)),ranges:n,linewise:r}}let ph=null;Mi.copy=Mi.cut=(t,e)=>{if(!jo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;ph=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=Gb?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let o=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(o&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return hh(t,{from:f,to:h,insert:t.state.toText(o)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(o=>o.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>o+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ox(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=o,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>vc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let o=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=o.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:o.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fo*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(o>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,o-=u.size}else break;else if(s=o&&c(this.lineAt(0,Rt.ByPos,r,s,o))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ax{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,o=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);c=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else c=this.height/o;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:o,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let o=r[r.length-1];o instanceof hn?r[r.length-1]=new hn(o.length+s):r.push(null,new hn(s-1))}if(e>0){let o=r[0];o instanceof hn?r[0]=new hn(e+o.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let o=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=o&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=vc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=o&&c.push(null,new hn(o-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=vc||Math.abs(f-this.heightMetrics(e,n).perLine)>=vc)&&(ml=!0),wc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class oj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let o=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,o).join(h)}forEachLine(e,n,r,s,o,c){let u=s+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,o);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let o=[];e>0&&this.decomposeLeft(e,o);let c=o.length;for(let u of r)o.push(u);if(e>0&&cx(o,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=wc(this.left,e),this.right=wc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:o,right:c}=this,u=n+o.length+this.break,f=null;return s&&s.from<=n+o.length&&s.more?f=o=o.updateHeight(e,n,r,s):o.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(o,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const aj=5;class mh{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=aj)&&this.addLineDeco(s,o,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();o=Math.max(o,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:o-n.left,right:Math.max(o,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class gh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=on.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:o,to:c})=>s>=o&&s<=c)){let{from:o,to:c}=this.lineBlockAt(s);e.push(new Sc(o,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new yh(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(_o(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,o=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ox(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,o=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(o,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ox();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,o=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new Sc(s.lineAt(c-r*1e3,Rt.ByHeight,o,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,o,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,o,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&o>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new gh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(o,c){r.push({from:o,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||_o(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||_o(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return _o(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}}class Sc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,o=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),o+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:o,to:c}=e[s],u=c-o;if(r<=u)return o+r;r-=u}}function kc(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(uc).filter(r=>typeof r!="function"),n=t.facet(sh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class yh{constructor(e,n,r){let s=0,o=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-o)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),o=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let o=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function _o(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>_o(s,e)):t._content)}const Cc=Ue.define({combine:t=>t.join(" ")}),bh=Ue.define({combine:t=>t.indexOf(!0)>-1}),xh=ol.newName(),hx=ol.newName(),px=ol.newName(),mx={"&light":"."+hx,"&dark":"."+px};function vh(t,e,n){return new ol(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=vh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),wh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!jo(this.dom,s))return;let o=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&Eo(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=To(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=jo(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&cl(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let o of e){let c=this.readMutation(o);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&jo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!gc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return Eo(c.node,c.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:o,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&othis.to&&(f=o);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));gc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);hh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],o=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let o of r.getTextFormats()){let c=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),h=this.toEditorPos(o.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=To(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((o,c,u,f,h)=>{if(r)return;let g=h.length-(c-o);if(s&&c>=s.to)if(s.from==o&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(o+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(othis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(o=>r(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(cc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new ih(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,o=this.state;for(let v of e){if(v.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=v.state}if(this.destroyed){this.viewState.state=o;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(o,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(g=null)):this.observer.clear(),o.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(o);s=dc.create(this,o,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(cc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Nc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Cc)!=s.state.facet(Cc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(eh))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new ih(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let o of r){let c=n.indexOf(o);if(c<0)s.push(new ih(o));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))o=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);o=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=dc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?o<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(eh))f(n)}get themeClasses(){return xh+" "+(this.state.facet(bh)?px:hx)+" "+this.state.facet(Cc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,rh,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),o=tb(this.dom,this.editorAttrs,e);return s||o});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let e=this.state.facet(Xe.cspNonce);ol.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return dh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return dh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),o=r[n?r.length-1:0];return ke.cursor(o.side(n,s)+e.from,o.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return dh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=fh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),fh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,o.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==n&&(o.fresh||mb(o.isolates,r=Mb(this,e))))return o.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Nc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(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,n={}){var r,s,o,c;return cc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(o=n.yMargin)!==null&&o!==void 0?o:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return cc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=ol.newName(),s=[Cc.of(r),Ro.of(vh(`.${r}`,e))];return n&&n.dark&&s.push(bh.of(!0)),s}static baseTheme(e){return Qa.lowest(Ro.of(vh("."+xh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ro,Xe.inputHandler=Sb,Xe.clipboardInputFilter=th,Xe.clipboardOutputFilter=nh,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=eh,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=uc,Xe.blockWrappers=Eb,Xe.outerDecorations=sh,Xe.atomicRanges=Mo,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=bh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=rh,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Nc{constructor(e,n,r,s,o,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=o,this.order=c}static update(e,n){if(n.empty&&!e.some(o=>o.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let o=Math.max(0,e.length-10);o=0;s--){let o=r[s],c=typeof o=="function"?o(t):o;c&&Kf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,o,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},o=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,Sh))}let f=c[e]||c.key;if(f)for(let h of u)o(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&o(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let Sh=null;function Ej(t,e,n,r){Sh=e;let s=UN(e),o=kN(s,0),c=CN(o)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Tc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Tc(A,e,!0)])||e.shiftKey&&(C=Ao[e.keyCode])!=s&&C!=A&&v(w[u+Tc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Tc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),Sh=null,f}class Ds{constructor(e,n,r,s,o){this.className=e,this.left=n,this.top=r,this.width=s,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let o=Sx(e);return[new Ds(n,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let o=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:o.left+1,y:c}),f=t.posAtCoords({x:o.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),o=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=uh(t,r,1),A=uh(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;we>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(we,q),L==null&&we>=be,ae.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(jc)!=e.state.facet(jc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(jc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const jc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),jc.of(t)]}const gl=Ue.define({combine(t){return Rf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(o&&Oe.ios&&n.iosSelectionHandles)){let c=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let o of Ds.forRange(t,"cm-selectionBackground",s))e.push(o);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Qa.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=on.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return on.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const Ec=Ue.define(),Hj=Ue.define(),Oc=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Oc).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Ec),this.view.viewport.from),r=[],s=this.gutters.map(o=>new Vj(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let c=!0;for(let u of o.type)if(u.type==fn.Text&&c){Ah(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(o.type==fn.Text){Ah(n,r,o.from);for(let c of s)c.line(this.view,o,r)}else if(o.widget)for(let c of s)c.widget(this.view,o);for(let o of s)o.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Oc),n=t.state.facet(Oc),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Ec),t.state.facet(Ec),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let o of n){let c=e.indexOf(o);c<0?s.push(new Ox(this.view,o)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let o of this.gutters)o.dom.remove(),s.indexOf(o)<0&&o.destroy();for(let o of s)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Ah(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,o=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,o,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,o,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Ah(this.cursor,s,n.from),r.length&&(s=s.concat(r));let o=this.gutter.config.lineMarker(e,n,s);o&&s.unshift(o);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let o of e.state.facet(Hj)){let c=o(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let o=s.target,c;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let o=0,c=0;;){let u=c,f=oo(u,f,h)||c(u,f,h):c}return r}})}});class kh extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ch(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Oc.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new kh(Ch(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let o=s(e,n,r);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new kh(Ch(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=Ch(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new kh(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Nh{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class Lo{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(s)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return s}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 n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),o=-1;o<(s?s.length:0);o++){let c=n[o<0?r.name:s[o]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Mc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,o){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,o&&o.length){this.props=Object.create(null);for(let[c,u]of o)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=Lo.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Eh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Mc.get(this)||this.topNode,o=new Eh(s);return o.moveTo(e,n),Mc.set(this,o._tree),o}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=qo(Mc.get(this)||this.topNode,e,n,!1);return Mc.set(this,r),r}resolveInner(e,n=0){let r=qo(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:o=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=o&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Mh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Th{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Th(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,o=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function qo(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(o&Pt.EnterBracketed&&g instanceof pn&&(v=Lo.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(o&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(o&Pt.IncludeAnonymous||!g.type.isAnonymous||Oh(g)){let w;if(!(o&Pt.IgnoreMounts)&&(w=Lo.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return o&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,o)}}}if(o&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=Lo.get(this._tree))&&s.overlay){let o=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=o:u=o:f>o))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return o}for(;;){if(r!=null&&s.type.is(r))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return r==null?o:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,o=r.buffer[this.index+3];if(o>s){let c=r.buffer[this.index+1];e.push(r.slice(s,o,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let o=1;on.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+o.from,-1,o);(s||(s=[r])).push(qo(u,e,n,!1))}}return s?Ix(s):r}class Eh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let o=n+e,c=e<0?-1:r._tree.children.length;o!=c;o+=e){let u=r._tree.children[o];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Oh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=o+1;break e}s=this.stack[--o]}for(let s=r;s=0;o--){if(o<0)return jh(this._tree,e,s);let c=r[n.buffer[this.stack[o]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Oh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Oh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:o=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Th(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=o[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],ae,he,we=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);ae=new Ur(T,be-he.start,r),we=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);ae=Mh(J,z,me,0,z.length,0,be-ee,qe,qe)}else ae=C(J,z,me,be-ee,ge-be,q)}M.push(ae),G.push(we)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(yt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[yt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[yt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Rc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Rc(t,r)}Hx.set(e,n)}return n}function Mh(t,e,n,r,s,o,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Mh(t,A,C,R,j,_,M,null,f))}v.push(_+O-o)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,o=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(o?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let o of n)o.to>e.length&&s.push(o);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],o=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=onew Nh(s.from,s.to)):[new Nh(0,0)]:[new Nh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let o=s.advance();if(o)return o}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let o of n.set)s.set.push(o);return s}static defineModifier(e){let n=new Dc(e);return r=>r.modified.indexOf(n)>-1?r:Dc.get(r.base||r,r.modified.concat(n).sort((s,o)=>s.id-o.id))}}let lE=0;class Dc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&oE(n,u.modified));if(r)return r;let s=[],o=new yi(e.name,s,e,n);for(let u of n)u.instances.push(o);let c=aE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Dc.get(u,f));return o}}function oE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function aE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let o=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(o.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=o.length-1,h=o[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new _c(r,c,f>0?o.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let o=new _c(s.tags,s.mode,s.context);n?n.next=o:r=o,n=o}return r}});class _c{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of o)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const Ee=yi.define,Lc=Ee(),Fr=Ee(),zx=Ee(Fr),Ux=Ee(Fr),Pr=Ee(),qc=Ee(Pr),Rh=Ee(Pr),Yi=Ee(),Ls=Ee(Yi),Ki=Ee(),Gi=Ee(),Dh=Ee(),Bo=Ee(Dh),Bc=Ee(),rt={comment:Lc,lineComment:Ee(Lc),blockComment:Ee(Lc),docComment:Ee(Lc),name:Fr,variableName:Ee(Fr),typeName:zx,tagName:Ee(zx),propertyName:Ux,attributeName:Ee(Ux),className:Ee(Fr),labelName:Ee(Fr),namespace:Ee(Fr),macroName:Ee(Fr),literal:Pr,string:qc,docString:Ee(qc),character:Ee(qc),attributeValue:Ee(qc),number:Rh,integer:Ee(Rh),float:Ee(Rh),bool:Ee(Pr),regexp:Ee(Pr),escape:Ee(Pr),color:Ee(Pr),url:Ee(Pr),keyword:Ki,self:Ee(Ki),null:Ee(Ki),atom:Ee(Ki),unit:Ee(Ki),modifier:Ee(Ki),operatorKeyword:Ee(Ki),controlKeyword:Ee(Ki),definitionKeyword:Ee(Ki),moduleKeyword:Ee(Ki),operator:Gi,derefOperator:Ee(Gi),arithmeticOperator:Ee(Gi),logicOperator:Ee(Gi),bitwiseOperator:Ee(Gi),compareOperator:Ee(Gi),updateOperator:Ee(Gi),definitionOperator:Ee(Gi),typeOperator:Ee(Gi),controlOperator:Ee(Gi),punctuation:Dh,separator:Ee(Dh),bracket:Bo,angleBracket:Ee(Bo),squareBracket:Ee(Bo),paren:Ee(Bo),brace:Ee(Bo),content:Yi,heading:Ls,heading1:Ee(Ls),heading2:Ee(Ls),heading3:Ee(Ls),heading4:Ee(Ls),heading5:Ee(Ls),heading6:Ee(Ls),contentSeparator:Ee(Yi),list:Ee(Yi),quote:Ee(Yi),emphasis:Ee(Yi),strong:Ee(Yi),link:Ee(Yi),monospace:Ee(Yi),strikethrough:Ee(Yi),inserted:Ee(),deleted:Ee(),changed:Ee(),invalid:Ee(),meta:Bc,documentMeta:Ee(Bc),annotation:Ee(Bc),processingInstruction:Ee(Bc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var _h;const $c=new yt,fE=new yt;class ar{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((o,c,u)=>{let f=Vx(o,c,u),h=f.type.prop($c);if(!h)return[];let g=o.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,o)){let A=o.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop($c)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(o,c)=>{if(o.prop($c)==this.data){r.push({from:c,to:c+o.length});return}let u=o.prop(yt.mounted);if(u){if(u.tree.prop($c)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+o.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let $o=null;class Ic{constructor(e,n,r=[],s,o,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=o,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Ic(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=$o;$o=this;try{return e()}finally{$o=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:o,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,o=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let o=s[0].from,c=s[s.length-1].to;return{parsedPos:o,advance(){let f=$o;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return $o}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Ic.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}ar.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(ar.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Lh=typeof navigator<"u"&&(!((_h=navigator.scheduling)===null||_h===void 0)&&_h.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=o.context.work(()=>Lh&&Lh()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ar.setState.of(new bl(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[ar.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),qh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Hc(t){let e=t.facet(qh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function zc(t,e){let n="",r=t.tabSize,s=t.facet(qh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let o=0;o=e?yE(t,n,e):null}class Uc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Hc(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:o}=this.options;return s!=null&&s>=r.from&&s<=r.to?o&&s==e?{text:"",from:e}:(n<0?s-1&&(o+=c-this.countColumn(r,r.search(/\S|$/))),o}countColumn(e,n=e.length){return nc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),o=this.options.overrideIndentation;if(o){let c=o(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let o=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)o.push(c);for(let c=o.length-1;c>=0;c--)r={node:o[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(Bh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,o=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,o&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class Bh extends Uc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Bh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(n.from),c=s==null||s<=o.from?o.to:Math.min(o.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let o=t.textAfter,c=o.match(/^\s*/)[0].length,u=r&&o.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function $h(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function Ih(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,o=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=$h(f.type,n,o);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,o)}}return jE(t,e,n,c,u.type,s,o)}function TE(t,e,n,r,s,o,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&o.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=o;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Hh(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Hh(h,`Modifier ${h} used at start of tag`):f.length?Hh(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Hh(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),o=Jx[s];if(o)return o.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Uh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function zh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=zh($E,0),_E=zh(Qx,0),LE=zh((t,e)=>Qx(t,e,BE(e)),0);function Uh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Io=50;function qE(t,{open:e,close:n},r,s){let o=t.sliceDoc(r-Io,r),c=t.sliceDoc(s,s+Io),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(c)[0].length,h=o.length-u;if(o.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*Io?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+Io),b=t.sliceDoc(s-Io,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(o=>Uh(e,o.from).block);if(!r.every(o=>o))return null;let s=n.map((o,c)=>qE(e,r[c],o.from,o.to));if(t!=2&&!s.every(o=>o))return{changes:e.changes(n.map((o,c)=>s[c]?[]:[{from:o.from,insert:r[c].open+" "},{from:o.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(o=>o)){let o=[];for(let c=0,u;cs&&(o==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;vo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&o.push({from:u.from+h,insert:f+" "});let c=e.changes(o);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,o.push({from:h,to:g})}return{changes:o}}return null}const Vh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Rf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Vh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Fc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return o?t=t.addChanges(o,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Fh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Vc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let o=s.pop(t,n,e);return o?(r(o),!0):!1}}const ev=Vc(0,!1),Fh=Vc(1,!1),UE=Vc(0,!0),VE=Vc(1,!0);class zn{constructor(e,n,r,s,o){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=o}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let o=s(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Fc(t,e,n,r){let s=e+1>n+20?e-n-1:0,o=t.slice(s,e);return o.push(r),o}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,o)=>n.push(s,o)),e.iterChangedRanges((s,o,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Fc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Ph(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let o=t.slice(0,n);return o[n-1]=s,o}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(o):o;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(o),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,o){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Pc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function ov(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Pc(n,e))}const JE=t=>ov(t,!Nn(t)),QE=t=>ov(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let o=r.type.prop(s),c,u;return o&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Yc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Yc(t.state,e,Nn(t)));function av(t,e){return _i(t,n=>{if(!n.empty)return Pc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>av(t,!1),uv=t=>av(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Pc(c,e));if(s.eq(r.selection))return!1;let o;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Yh=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(s=ke.cursor(r.from+o))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function oO(t,e,n){let r=!1,s=wl(t.selection,o=>{let c=vl(t,o.head,-1)||vl(t,o.head,1)||o.head>0&&vl(t,o.head-1,1)||o.headoO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let o=n(s);return ke.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Yc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Yc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Gc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),o=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let o of n.selection.ranges){let c=n.doc.lineAt(o.head);if(e?c.to0)for(let u=o;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ho(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(o=>{let{from:c,to:u}=o;if(c==u){let f=e(o);fc&&(n="delete.forward",f=Kc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Kc(t,c,!1),u=Kc(t,u,!0);return c==u?{range:o}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,o)=>{se&&(e=n?o:s)});return e}const Ev=(t,e,n)=>Ho(t,r=>{let s=r.from,{state:o}=t,c=o.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ho(t,n=>{let r=n.head,{state:s}=t,o=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?o.to:o.from)){r==n.head&&o.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(o.text,r-o.from,e)+o.from,h=o.text.slice(Math.min(r,f)-o.from,Math.max(r,f)-o.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ho(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headHo(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ho(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,o=t.doc.lineAt(s),c=s==o.from?s-1:kn(o.text,s-o.from,!1)+o.from,u=s==o.to?s+1:kn(o.text,s-o.from,!0)+o.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=o.to,c.ranges.push(r)}else e.push({from:s.from,to:o.to,ranges:[r]});n=o.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let o of Gc(t)){if(n?o.to==t.doc.length:o.from==0)continue;let c=t.doc.lineAt(n?o.to+1:o.from-1),u=c.length+1;if(n){r.push({from:o.to,to:c.to},{from:o.from,insert:c.text+t.lineBreak});for(let f of o.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:o.from},{from:o.to,insert:t.lineBreak+c.text});for(let f of o.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let o of Gc(t))n?r.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):r.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Gc(e).map(({from:s,to:o})=>(s>0?s--:o{let o;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(o=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,o)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),o;return r&&s&&r.to<=e&&s.from>=e&&(o=r.type.prop(yt.closedBy))&&o.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:o,to:c}=s,u=e.doc.lineAt(o),f=!t&&o==c&&qO(e,o);t&&(o=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new Uc(e,{simulateBreak:o,simulateDoubleBreak:!!f}),g=Yx(h,o);for(g==null&&(g=nc(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));cu.from&&o{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let o=t.changes(s);return{changes:s,range:ke.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Uc(t,{overrideIndentation:o=>{let c=n[o];return c??-1}}),s=Gh(t,(o,c,u)=>{let f=Yx(r,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let h=/^\s*/.exec(o.text)[0],g=zc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(qh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let o=nc(s,t.tabSize),c=0,u=zc(t,Math.max(0,o-Hc(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Kh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Yh}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Yh,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Yh,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Kh,shift:Kh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:aO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:o}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),o!==void 0&&(c["aria-expanded"]=String(o)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const zo=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:o=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,ae=J)=>{const he=O.current;if(!he)return;const we=he.state.doc.length,T=Math.max(0,Math.min(J,we)),z=Math.max(0,Math.min(ae,we));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const ae=O.current;if(!ae)return null;const he=Math.max(0,Math.min(J,ae.state.doc.length)),we=ae.coordsAtPos(he);return we?{left:we.left,right:we.right,top:we.top,bottom:we.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,ae=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Qa.highest(Xe.domEventHandlers({keydown:we=>(_.current?.(we),we.defaultPrevented)})),Xe.updateListener.of(we=>{we.docChanged&&!L.current&&j.current(we.state.doc.toString()),(we.selectionSet||we.docChanged)&&R.current?.(we.state.selection.main.head)})]}),he=new Xe({state:ae,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const ae=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(ae.anchor,e.length),head:Math.min(ae.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(o,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});zo.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Xh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(o,c)=>n(e.map((u,f)=>f===o?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((o,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:o.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:o.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:o.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||po(t),s=n==="dark",o=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Xh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(zo,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:o,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Xh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${o}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${o}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Xh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${o}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(zo,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(zo,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const o=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,o]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>o(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>o("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} -});`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;a{const u=a.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` +`).map(o=>{const u=o.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` `)}function Pv(t,e){return t.slice(0,Math.max(0,Math.min(e,t.length))).replace(/\r\n?/g,` `).length}function Yv(t,e,n){const r=t.split(` `),s=e.split(` -`),a=t.slice(0,Math.max(0,Math.min(n,t.length))),c=a.split(` -`).length-1,u=a.lastIndexOf(` -`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),o=t.slice(0,Math.max(0,Math.min(n,t.length))),c=o.split(` +`).length-1,u=o.lastIndexOf(` +`),f=o.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),o=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(o,s.length),selectionEnd:Math.min(Math.max(o,c),s.length)}}const Jh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Jh,"flex.collection":Jh,"flex.variables":Jh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,o)=>s.localeCompare(o)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,o]of r){const c=n.match(s);if(c)return{path:o,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function o3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function a3(t,e,n,r={},s=!1){const o=Math.max(0,Math.min(e,t.length)),c=t.slice(0,o),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:o-u.prefix.length,to:o,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:o-f.prefix.length,to:o,items:v}:null}const h=o3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:o-h.prefix.length,to:o,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:o-g.length,to:o,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:o={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,ae=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,ae))})},j=(B,K,ee=!1)=>{const be=a3(B,K,r,o,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(ao,{className:"h-3.5 w-3.5"}):p.jsx(Od,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(zo,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Xc="API-host execute route",Jc="the execute path";function Qc(t,e){return`${Xc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Qc("was unauthorized",`documentation authentication for ${Jc}`):t===403?Qc("was rejected",`CSRF, same-origin, and authorization middleware for ${Jc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Xc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Xc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Jc}.`:Qc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const o=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await o.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return o.status===429||o.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):o.redirected?Qc("was redirected",`authentication middleware for ${Jc}`):o.ok?`${Xc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(o.status,o.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Qh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Qh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Qh(n);if(!r)return t;const s=Qh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const o=new URL(t),c=`${o.pathname==="/"?"":o.pathname}${o.search}${o.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||po(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:o}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${o}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${o}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),o=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:o}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:o="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",ae=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",we=J||ae||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(ae),[qe,He]=I.useState(he),Je=I.useRef(we),$e=I.useRef(we),[ft,At]=I.useState(null),[bt,Ge]=I.useState(),[Q,re]=I.useState(null),[Se,Ne]=I.useState(null),[Be,We]=I.useState([]),[lt,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),ve=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Te=["GET","HEAD"].includes(Ae),je=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${je}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&o!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Fo=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=po(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Fo},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>o==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${le}-script-tab-${se}`,En=se=>`${le}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&o!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),ve.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Po=E?E(T.auth):T.auth,Qr=Pa({request:{...T,auth:Po},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),lu=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(ft,{...T,auth:Po},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ht(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Be.filter(se=>se.passed).length,Yo=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Yo&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${je}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||$e.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${je}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{ve.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Te&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:je,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:je,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(xf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:o==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>lu(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),o==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${je}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),o==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${je}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(bf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Yo,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(co,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),Se&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Se]}),ft&&p.jsx(QO,{response:ft,theme:s,curlCommand:bt,advanced:o==="advanced"}),Be.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Be.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Be.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),lt.length>0&&p.jsx(Rr,{code:lt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Wh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:o,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(o,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(o||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>hf(K),[K]),ae=t1(D,_)!==t1(w.request,A),he=C==="advanced",we=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Wh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(bf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${we}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&ae&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(La,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${we}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Wh("tab",ne)},onScriptTabChange:ne=>{B(ne),Wh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>pf(Ce,ne))})]})};function Wc(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(t){if(!t)return"";try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"?e.origin:""}catch{return""}}function T3(t,e,n,r){const s=e.startsWith("/")?e:`/${e}`;return{method:t.toUpperCase(),url:n?`${n}${s}`:s,auth:{type:"none"},...r?{hostExecution:{preferHostExecution:!0}}:{}}}function j3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function E3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const O3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:o,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=j3(),h=o??nf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L){if(!(c?.runtimeOnly?.some(lt=>lt.path===e&<.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(lt=>lt.code==="runtime.operation-undocumented"&<.location.path===e&<.location.method?.toUpperCase()===n.toUpperCase())))return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const Se=N3(c?.serverOrigin),Ne=s.tryIt?.hostExecution,Be=Ne?.available===!0&&Ne.preferHostExecution!==!1,We=()=>u?.({request:T3(n,e,Se,Be),serverUrl:Se||void 0,scripts:{preRequest:"",tests:""},requestTab:"params",scriptTab:"pre-request"});return p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsxs("dl",{className:`mt-4 space-y-3 text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:[p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.contractEvidence||"Contract"}),p.jsx("dd",{children:ce?.contractNotDeclared||"OpenAPI does not declare this operation."})]}),p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.runtimeEvidence||"Runtime"}),p.jsx("dd",{children:ce?.runtimeRouteUndocumented||`${n.toUpperCase()} ${e} is registered by the running service.`})]})]}),u&&p.jsxs("button",{type:"button",className:"mt-4 inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:We,children:[p.jsx(La,{className:"h-4 w-4"}),ce?.openApiClient||"Open in API Client"]})]})}if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",ae=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,we={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const Se=!A.has(re);w(Ne=>{const Be=new Set(Ne.key===b?Ne.sections:g);return Be.has(re)?Be.delete(re):Be.add(re),{key:b,sections:Be}}),re==="tryIt"&&E3("tryIt",Se?"1":void 0)},He=(re,Se,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Se}-heading`,children:[p.jsxs("button",{type:"button",id:`${Se}-heading`,"aria-expanded":A.has(Se),onClick:()=>qe(Se),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Se)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(Se)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},$e=(re,Se)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=ae.indexOf(Se),Be=re.key==="Home"?ae[0]:re.key==="End"?ae[ae.length-1]:re.key==="ArrowRight"?ae[(Ne+1)%ae.length]:ae[(Ne-1+ae.length)%ae.length];Je(Be)},ft=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wc(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,bt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{ft()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Cd,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&bt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:bt.map(([re,Se])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof Se=="string"?Se:JSON.stringify(Se)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...we})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,Se])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),Se.schema&&p.jsx(Dr,{spec:t,schema:Se.schema,theme:r,...we}),Se.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Se.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,Se])=>{const Ne=In.isReference(Se)?In.resolveReference(t,Se.$ref):Se;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([Be,We])=>{const lt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:Be}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...we})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),lt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(lt.value??lt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Be)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:ae.map(re=>p.jsx("button",{ref:Se=>{R.current[re]=Se},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:Se=>$e(Se,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function M3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function R3(t,e){let n=M3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function D3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const o of In.getHttpMethods(s)){const c=s[o];n.push({path:r,method:o,operation:c,score:R3(c,o),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const _3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",o=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=D3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:o,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${o}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${o}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${o}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${o}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${o}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${o}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(La,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(La,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${o}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${o}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const L3=typeof n1>"u"?{commit:"unknown"}:n1,q3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=L3,o=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),o]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},B3=(t,e,n)=>t==="dark"?n:e,$3="Runtime intelligence returned an invalid snapshot.",I3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),H3=new Set(["error","warning","info"]),z3=new Set(["pass","warn","fail","partial"]);function sn(){throw new Error($3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&sn(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&sn(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];sn()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&sn(),n}function U3(t){return Ji(t)||sn(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||sn(),t.map(U3)}function V3(t){(!Ji(t)||!Ji(t.location))&&sn();const e=Un(t,"code"),n=Un(t,"severity");(!I3.has(e)||!H3.has(n)||t.location.kind!=="operation")&&sn();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const o=i1(t,"expected");o!==void 0&&(r.expected=o);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),t.disposition!==void 0&&(t.disposition!=="acknowledged"&&sn(),r.disposition="acknowledged"),r}function F3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&sn();const e=Un(t,"status");z3.has(e)||sn();const n=t.findings.map(V3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&sn();const o=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==o&&sn(),{status:e,complete:t.complete,findings:n,summary:r}}function P3(t){Ji(t)||sn(),(!Ji(t.runtime)||!Ji(t.summary))&&sn(),typeof t.discoveryComplete!="boolean"&&sn();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const o=Zh(t,"serverOrigin");if(o&&(r.serverOrigin=o),t.server!==void 0){Ji(t.server)||sn();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&sn(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||sn(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=F3(t.validation)),r}const Y3=60;function K3(t,e,n=Y3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function G3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const X3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:o,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:o},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,o,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=K3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=G3(C.current);if(!J.length)return;const ae=J[0],he=J[J.length-1],we=document.activeElement;q.shiftKey&&(we===ae||!C.current.contains(we))?(q.preventDefault(),he.focus()):!q.shiftKey&&(we===he||!C.current.contains(we))&&(q.preventDefault(),ae.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},J3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function Q3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:o,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=W3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(o)?o.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:Q3(o),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(o)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),J3[D]]},D))]}),o!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function eM(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const tM=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:o,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),o();return}if(j.key!=="Tab"||!f.current)return;const R=eM(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,o]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:o}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:o,children:p.jsx(Md,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(nM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),o())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function nM({result:t,theme:e,messages:n,onSelect:r}){const o=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:o,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code}),u.disposition==="acknowledged"&&p.jsx("span",{children:n?.acknowledgedFinding||"acknowledged"})]}),p.jsx("div",{className:`mt-1 text-xs ${o}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${o}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${o}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:o,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>o?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>o(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function iM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Zc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function eu(t){return Array.isArray(t)?`[${t.map(eu).join(",")}]`:Zc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${eu(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function rM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function o1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){o1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function sM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function a1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let o=n?s.get(n):void 0;for(;o&&!r.has(o.id);)r.add(o.id),o=o.parentFolderId?s.get(o.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const o of t.folders)o.collectionId!==e||!o.parentFolderId||r.has(o.id)||r.has(o.parentFolderId)&&(r.add(o.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const o=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))o.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&o.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function lM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[sM(r)],activeEnvironmentId:r.id}}function oM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=a1(r,e),o=f1(r,e);h1(o,e);const c=lM(r,n.environmentId),u={version:6,collections:[rM(s)],folders:d1(r,e),requests:o,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function aM(t){if(!Zc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function tu(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function cM(t,e){const n=a1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(o=>o.id===e.folderId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(o=>o.id===e.requestId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function uM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function dM(t){if(!Zc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Zc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=aM(t.scope),n=uM(t.workspace),r=oy(n);if(eu(n)!==eu(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");tu(r.collections,"collection"),tu(r.folders,"folder"),tu(r.requests,"request"),tu(r.environments,"environment"),cM(r,e);for(const s of r.requests)o1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function fM(t){return`${JSON.stringify(dM(t),null,2)} +`}function hM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let o=!0;for(;o;){o=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),o=!0)}return s}function Sl(t,e,n){const r=hM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function pM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(o=>o.id===e)?.name||"Deleted collection";if(!n)return r;const s=pM(t.folders.filter(o=>o.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function mM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function gM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const o=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=pf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&mM(E);let j;E.result&&!D&&(s=ay(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(o.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=o.filter(g=>g.cancelled).length,h=o.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:o.length,passed:u,failed:h,cancelled:f,stopped:c,items:o,workspace:s}}function Gr(){return new Date().toISOString()}function yM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const bM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:o,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,Se=(Ne,Be)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:Be}),Se(We.id,Be+1))})};return Se(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),Se(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],Se=new Set;let Ne=K.get(Q);for(;Ne&&!Se.has(Ne.id);)Se.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const Se=oM(h,Q),Ne=new Blob([fM(Se)],{type:"application/json;charset=utf-8"}),Be=URL.createObjectURL(Ne),We=document.createElement("a");We.href=Be,We.download=yM(re),We.click(),setTimeout(()=>URL.revokeObjectURL(Be),0),L("")}catch(Se){L(Se instanceof Error?Se.message:String(Se))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),Se=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:Se,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(Se),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(Se=>({...Se,folders:Se.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},ae=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(Se=>Se.id===M.id?{...Se,variables:[...Se.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:Se)}))},he=(Q,re)=>{if(!M)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Be=>Be.id===M.id?{...Be,variables:Be.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:Se}:Be)}))},we=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter(Be=>Be.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),Se=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:Se,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(Se),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map(Be=>Be.id===j?{...Be,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:Be)}));return}const Se={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,Se]})),R(Se.id),O(Q)},me=Q=>{const re=h.requests.find(Se=>Se.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(Se=>Se.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(Se=>Se.id===Q);g(Se=>LC(Se,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",$e=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),ft=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=be(Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return p.jsxs(kd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Be}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${Be} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},Be),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(lt=>ft(lt,re+1,Ne))]},Q.id)},At=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=Y.filter(lt=>lt.folderId===Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return Be.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Be.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:Be.map($e)})]}),We.map(lt=>At(lt,re+1,Ne))]},Q.id)},bt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>o?.(Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(xf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:ae,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:Se=>he(Q.id,{enabled:Se.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:Se=>he(Q.id,{key:Se.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:Se=>he(Q.id,{value:Se.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>we(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),bt.map(Q=>ft(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(xf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map($e),bt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function Uo(){return new Date().toISOString()}const xM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),o=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=Uo(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!o)return;const w=Uo();e(A=>({...A,environments:A.environments.map(C=>C.id===o.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!o)return;const C=Uo();e(E=>({...E,environments:E.environments.map(D=>D.id===o.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),o&&p.jsx("button",{type:"button","aria-label":`Delete environment ${o.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,o.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),o&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:o.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[o.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),o.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function nu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function vM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",o=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,o,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=nu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function wM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),o=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:o,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const o=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=kd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` -`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${o}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:o,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${o}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":o,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":o}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${o}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${o}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function op(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function AM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=AM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,o)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${o}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const kM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:o,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:o||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>vM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>wM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},ae=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],we=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:ae,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=nu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[op(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:nu(ne)?"text-red-600":j,children:op(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:nu(B)?"text-red-600":j,children:op(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[we,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ot(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?ot(r.value):""}function CM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function ap(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=CM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const o=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return o("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){o("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return o("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){o("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(o("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const o=ot(r.key).trim();return o?[{id:An("variable"),key:o,value:ot(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function NM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(o=>t.includes(o));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function TM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(ot).join(` +`):ot(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,o)=>{const c=ot(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${o}]`,f=TM(s.script,`${u}.script`,n).trim();if(!f)return;const h=NM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function jM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function EM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(o=>{const c=o.indexOf("=");return{key:S1(c>=0?o.slice(0,c):o),value:S1(c>=0?o.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function OM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function MM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=ot(r.key).trim();s&&(n=n.replace(new RegExp(`:${MM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function RM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=OM(t.query),n=ot(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=ot(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(ot).join("."):ot(t.host),o=ot(t.port),c=Array.isArray(t.path)?t.path.map(ot).join("/"):ot(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${o?`:${o}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function DM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function _M(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function LM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function qM(t,e,n,r){const s=_M(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const o=ot(t.mode);if(o==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?ot(c.language):"";return{body:ot(t.raw),contentType:s||LM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(o==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:ot(u.key),value:ot(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(o==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=ot(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:ot(c.query),variables:u},contentType:s||"application/json"}}if(o==="formdata"){const c=Xr(t.formdata).map(f=>{const h=ot(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(ot).filter(Boolean).join(", "):ot(f.src);return{key:ot(f.key),value:h==="text"?ot(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(o==="file"){const c=mn(t.file)?ot(t.file.src):ot(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${o}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function BM(t,e,n,r,s,o,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=ot(f.method).trim().toUpperCase()||"GET",g=RM(f.url),b=DM(f.header),v=qM(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:ap(f.auth,{type:"inherit"},`${c}.auth`,u)},A=EM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:o,updatedAt:o}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=ot(e.name)||"Untitled",o=w1(e.event,`${r}.event`,t.warnings),c=jM(t.inheritedScripts,o);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:ap(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=BM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function $M(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=ot(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=ot(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),o=An("collection"),c={id:o,name:e,auth:ap(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:o,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function IM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=ot(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function HM(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:$M(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:IM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function zM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function UM(t,e){const n=zM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function VM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const FM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,o]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=HM(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?UM(M,G.result):VM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?o({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?o({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):o({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(ao,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function PM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e.folderId);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function YM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const KM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const ae=await gM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(we=>({...we,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(we=>({...we,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(ae.workspace),Y(he=>Object.fromEntries(C.map(we=>{const T=he[we.id]||{status:"pending"};return[we.id,T.status==="pending"&&ae.stopped?{status:"skipped"}:T]}))),M(ae),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(co,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(co,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,ae)=>{const he=G[J.id]||{status:"pending"},we=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=we?.status!==void 0&&we.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:ae+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:PM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(ao,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:YM(he)}),we?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",we.status]}),we?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(Nd,{className:"mr-1 inline h-3.5 w-3.5"}),we.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Vo(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function GM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return po(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function XM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:o="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=GM(t),Y=Sn(e),B=nl(),K=o===!1?{}:j1(o),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[ae,he]=I.useState(Y),[we,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[$e,ft]=I.useState({}),[At,bt]=I.useState(),[Ge,Q]=I.useState(B),[re,Se]=I.useState(B.collections[0]?.id),[Ne,Be]=I.useState(""),We=I.useRef(B.collections[0]?.id),lt=I.useRef(void 0),[ti,Tn]=I.useState(o===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(o===!1)return;let Me=!1;return hy(o).then(Ze=>{Me||(Q(Ze),Se(Ze.collections[0]?.id),Be(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[o]);const x=my(o,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>hf(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,ae),[ce,ae]),V=I.useMemo(()=>XM(ce,ae)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,ae,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),ve=I.useCallback(Me=>{Se(Me),Be("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},le=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),o!==!1&&Vo(o,{requestTab:Me}),C?.(Me)},Te=Me=>{qe(Me),o!==!1&&Vo(o,{scriptTab:Me}),E?.(Me)},je=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>pf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,lt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>ay(Ze,{...Me,collectionId:We.current,folderId:lt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Se(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Be(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),o!==!1&&Vo(o,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{Se(Me),Be(Ze||""),bt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{ft({entryId:Me,runId:Ze}),Je("history")},Fo=()=>ni(Me=>{const Ze=!Me;return o!==!1&&Vo(o,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Fo,children:ht?p.jsx(Ed,{className:"h-4 w-4"}):p.jsx(jd,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(bf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(FM,{onWorkspaceChange:Q,onSelectedCollectionChange:ve,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(xM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(bM,{request:ce,scripts:ae,onLoadRequest:Dt,onSelectedCollectionChange:ve,onSelectedFolderChange:Be,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),o!==!1&&Vo(o,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(kM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:$e.entryId,initialRunId:$e.runId,theme:kt},`${$e.runId||""}:${$e.entryId||""}`):He==="runner"&&At?p.jsx(KM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:we,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:je,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:le,onRequestTabChange:Ae,onScriptTabChange:Te,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function iu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function JM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,o]of Object.entries(t.paths))for(const c of In.getHttpMethods(o)){if(Wc(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function QM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${iu(n.padding.vertical)||"0"} ${iu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:iu(n.maxHeight)||"32px",maxWidth:iu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const WM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const o=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=ho(o),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:o,preferences:c})),ae=I.useRef(null),he=I.useRef(null),we=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===o?q.preferences:ho(o),Je=n&&He.theme||e,$e=Je==="high-contrast"?"dark":Je,ft=He.expand,At=He.expandedTags??["default"],bt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...JM($e,Ge),...r}),[$e,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return P3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const le=R1(t,window.location.hash);if(le){g(le);return}const Ae=window.location.hash.replace(/^#/,"");g(Te=>Te&&Ae&&Wc(Te.path,Te.method)===Ae?Te:null)},de=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const le=ae.current,Ae=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Te=je=>{if(je.key==="Escape"){je.preventDefault(),M(!1);return}if(je.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];je.shiftKey&&document.activeElement===ze?(je.preventDefault(),Ve.focus()):!je.shiftKey&&document.activeElement===Ve&&(je.preventDefault(),ze.focus())};return document.addEventListener("keydown",Te),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Te),de?.focus()}},[L]);const re=()=>{J({key:o,preferences:ho(o)})},Se=F=>{J(de=>{const le=de.key===o?de.preferences:ho(o);return{key:o,preferences:{...le,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>we.current?.scrollTo({top:0,behavior:"auto"})),Be=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wc(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},lt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!bt;Ba(o,"sidebarCollapsed",F),Se({sidebarCollapsed:F})},ht=nf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ft===void 0?ht:nf(ft),Vn=F=>{Ba(o,"expand",F),re()},qn=F=>{n&&(Ba(o,"theme",F),re())},kt=F=>{Ba(o,"expandedTags",F),Se({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=B3($e,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=$e==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=$e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),ve=p.jsx(pk,{spec:t,onEndpointSelect:Be,theme:$e,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.logo?p.jsx(QM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(iM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${bt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":bt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!bt&&ve}),p.jsxs("main",{ref:we,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(O3,{spec:t,path:h.path,method:h.method,theme:$e,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:lt}):p.jsx(_3,{spec:t,onEndpointSelect:Be,theme:$e}),p.jsx(q3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:$e,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:ae,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${$e==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:ve})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${$e==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(tM,{open:B&&T,theme:$e,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:Be,messages:X}),p.jsx(X3,{spec:t,theme:$e,messages:X,onEndpointSelect:Be,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>lt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Z3,{open:G,theme:$e,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:ft,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function ZM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function eR(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function tR(t,e){const n=e.load||ZM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),o={},c=new Map;async function u(g){if(g===r)return s;if(o[g])return o[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return o[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=eR(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(o).length&&(s[dp]=o),s}async function nR(t,e){return tR(t,e)}const ru="1",su=new WeakMap;function iR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=iR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},o=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!o.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function rR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function sR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=su.get(t);n&&n.unmount();const r=$A.createRoot(t);return su.set(t,r),r.render(e),()=>{su.get(t)===r&&su.delete(t),r.unmount()}}function $1(t,e,n){return sR(n),B1(t,p.jsx(WM,{spec:fp(e,n),theme:rR(n),options:n}))}function I1(t,e){const n={contractVersion:ru,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:ru,...e.options||{}},r=e.baseUri?await nR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:ru}),As.FLEXDOC_CONTRACT_VERSION=ru,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/rust-actix/assets/flexdoc.standalone.js b/adapters/rust-actix/assets/flexdoc.standalone.js index 3efc5433..bf78a4d9 100644 --- a/adapters/rust-actix/assets/flexdoc.standalone.js +++ b/adapters/rust-actix/assets/flexdoc.standalone.js @@ -1,86 +1,86 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(q,J){var oe=q.length;q.push(J);e:for(;0>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1>>1,we=q[he];if(0>>1;hes(me,ae))nes(Ce,me)?(q[he]=Ce,q[ne]=ae,he=ne):(q[he]=me,q[z]=ae,he=z);else if(nes(Ce,ae))q[he]=Ce,q[ne]=ae,he=ne;else break e}}return J}function s(q,J){var ae=q.sortIndex-J.sortIndex;return ae!==0?ae:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var we=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof we=="function"){b.callback=we,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=ae,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=ae,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,ae-he))):(q.sortIndex=we,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var ae=v;v=J;try{return q.apply(this,arguments)}finally{v=ae}}}})(vd)),vd}var Ng;function RA(){return Ng||(Ng=1,xd.exports=MA()),xd.exports}var wd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function($e){return $e})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ad.exports=_A(),Ad.exports}var Mg;function qA(){if(Mg)return oo;Mg=1;var t=RA(),e=Sd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1we||(i.current=he[we],he[we]=null,we--)}function me(i,l){we++,he[we]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function $e(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,a=Q2(l,i.type);l!==a&&(me(Ce,i),me(ne,a))}function ft(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oa._currentValue=ae)}var At,bt;function Ge(i){if(At===void 0)try{throw Error()}catch(a){var l=a.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",bt=-1)":-1m||$[d]!==te[m]){var fe=` -`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ge(a):""}function Se(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",a=null;do l+=Se(i,a),a=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var $e=Object.prototype.hasOwnProperty,We=t.unstable_scheduleCallback,vt=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ft=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,kt=t.unstable_NormalPriority,x=t.unstable_LowPriority,U=t.unstable_IdlePriority,pe=t.log,ue=t.unstable_setDisableYieldValue,X=null,k=null;function V(i){if(typeof pe=="function"&&ue(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var W=Math.clz32?Math.clz32:de,we=Math.log,F=Math.LN2;function de(i){return i>>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(ve(i)/F|0)|0}var le=256,Ae=262144,Te=4194304;function je(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,a){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=je(d):(S&=N,S!==0?m=je(S):a||(a=N&~i,a!==0&&(m=je(a))))):(N=d&~y,N!==0?m=je(N):S!==0?m=je(S):a||(a=d&~i,a!==0&&(m=je(a)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,a=l&-l,y>=a||y===32&&(a&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Te;return Te<<=1,(Te&62914560)===0&&(Te=4194304),i}function Fn(i){for(var l=[],a=0;31>a;a++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Fo(i,l,a,d,m,y){var S=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(a=S&~a;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var oR=/[\n"\\]/g;function vi(i){return i.replace(oR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,a,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):a!=null?gp(i,S,On(a)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,a,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}a=a!=null?""+On(a):"",l=l!=null?""+On(l):a,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,a){l==="number"&&ou(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Tl(i,l,a,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Go={};Object.defineProperty(Go,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Go,Go),window.removeEventListener("test",Go,Go)}catch{wp=!1}var es=null,Sp=null,cu=null;function Q1(){if(cu)return cu;var i,l=Sp,a=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Qo),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return LR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function BR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function $R(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),cu=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:a,offset:l-i};i=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=pw(a)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=ou(i.document);l instanceof i.HTMLIFrameElement;){try{var a=typeof l.contentWindow.location.href=="string"}catch{a=!1}if(a)i=l.contentWindow;else break;l=ou(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var YR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,ta=null,Rp=!1;function bw(i,l,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Rp||Rl==null||Rl!==ou(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),ta&&ea(ta,d)||(ta=d,d=nd(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|a<it?(dt=Ie,Ie=null):dt=Ie.sibling;var vt=ie(P,Ie,Z[it],ye);if(vt===null){Ie===null&&(Ie=dt);break}i&&Ie&&vt.alternate===null&&l(P,Ie),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt,Ie=dt}if(it===Z.length)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;itit?(dt=Ie,Ie=null):dt=Ie.sibling;var Ss=ie(P,Ie,vt.value,ye);if(Ss===null){Ie===null&&(Ie=dt);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),xt===null?Fe=Ss:xt.sibling=Ss,xt=Ss,Ie=dt}if(vt.done)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;!vt.done;it++,vt=Z.next())vt=xe(P,vt.value,ye),vt!==null&&(H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return pt&&gr(P,it),Fe}for(Ie=d(Ie);!vt.done;it++,vt=Z.next())vt=oe(Ie,P,it,vt.value,ye),vt!==null&&(i&&vt.alternate!==null&&Ie.delete(vt.key===null?it:vt.key),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return i&&Ie.forEach(function(fD){return l(P,fD)}),pt&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){a(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){a(P,H.sibling),ye=m(H,Z.props),oa(ye,Z),ye.return=P,P=ye;break e}a(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=xu(Z.type,Z.key,Z.props,null,P.mode,ye),oa(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){a(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{a(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,Nu(Z),ye);if(Z.$$typeof===j)return Et(P,H,Su(P,Z),ye);Tu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(a(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(a(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):a(P,H)}return function(P,H,Z,ye){try{la=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===ku)throw Ie;var xt=li(29,Ie,null,P.mode);return xt.lanes=ye,xt.return=P,xt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function os(i,l,a){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=bu(i),Cw(i,null,a),l}return yu(i,d,l,a),bu(i)}function aa(i,l,a){if(l=l.updateQueue,l!==null&&(l=l.shared,(a&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}function Zp(i,l){var a=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var m=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var S={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,a=a.next}while(a!==null);y===null?m=y=l:y=y.next=l}else m=y=l;a={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=l:i.next=l,a.lastBaseUpdate=l}var em=!1;function ca(){if(em){var i=zl;if(i!==null)throw i}}function ua(i,l,a,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,oe=ie!==N.lane;if(oe?(ut&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=a;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=m.callbacks,oe===null?m.callbacks=[ie]:oe.push(ie))}else oe={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=oe,$=xe):fe=fe.next=oe,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;oe=N,N=oe.next,oe.next=null,m.lastBaseUpdate=oe,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,a);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=t4($,d);ha(i,l,fe,di(i))}else ha(i,l,d,di(i))}catch(xe){ha(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function o4(){}function ym(i,l,a,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,ae,a===null?o4:function(){return AS(i),a(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ae},next:null};var a={};return l.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ha(i,l.next.queue,{},di())}function bm(){return yn(Oa)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function a4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var a=di();i=ls(a);var d=os(l,i,a);d!==null&&(Qn(d,l,a),aa(d,l,a)),l={cache:Kp()},i.payload=l;return}l=l.return}}function c4(i,l,a){var d=di();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bu(i)?TS(l,a):(a=qp(i,l,a,d),a!==null&&(Qn(a,i,d),jS(a,l,d)))}function NS(i,l,a){var d=di();ha(i,l,a,d)}function ha(i,l,a,d){var m={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,a);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return yu(i,l,m,0),Mt===null&&gu(),!1}catch{}if(a=qp(i,l,m,d),a!==null)return Qn(a,i,d),jS(a,l,d),!0}return!1}function xm(i,l,a,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Bu(i)){if(l)throw Error(r(479))}else l=qp(i,a,d,2),l!==null&&Qn(l,i,2)}function Bu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=Ou=!0;var a=i.pending;a===null?l.next=l:(l.next=a.next,a.next=l),i.pending=l}function jS(i,l,a){if((a&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}var pa={readContext:yn,use:Du,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};pa.useEffectEvent=zt;var ES={readContext:yn,use:Du,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,a){a=a!=null?a.concat([i]):null,Lu(4194308,4,gS.bind(null,l,i),a)},useLayoutEffect:function(i,l){return Lu(4194308,4,i,l)},useInsertionEffect:function(i,l){Lu(4,2,i,l)},useMemo:function(i,l){var a=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return a.memoizedState=[d,l],d},useReducer:function(i,l,a){var d=$n();if(a!==void 0){var m=a(l);if(Js){V(!0);try{a(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=c4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,a=NS.bind(null,nt,l);return l.dispatch=a,[i.memoizedState,a]},useDebugValue:mm,useDeferredValue:function(i,l){var a=$n();return gm(a,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,a){var d=nt,m=$n();if(pt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=l(),Mt===null)throw Error(r(349));(ut&127)!==0||Jw(d,l,a)}m.memoizedState=a;var y={value:a,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,a,l),null),a},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(pt){var a=Zi,d=Wi;a=(d&~(1<<32-W(d)-1)).toString(32)+a,l="_"+l+"R_"+a,a=Mu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,a),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,a=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,a)),i||is(l,!0)}else i=id(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(a=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),a!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else a=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return l.flags&256?(ai(l),l):(ai(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(ai(l),l):(ai(l),null)}return ai(l),(l.flags&128)!==0?(l.lanes=a,l):(a=d!==null,i=i!==null&&i.memoizedState!==null,a&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),a!==i&&a&&(l.child.flags|=8192),Uu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)ga(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Eu(i),y!==null){for(l.flags|=128,ga(d,!1),i=y.updateQueue,l.updateQueue=i,Uu(l,i),l.subtreeFlags=0,i=a,a=l.child;a!==null;)Nw(a,i),a=a.sibling;return me(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Ku&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304)}else{if(!m)if(i=Eu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Uu(l,i),ga(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Ku&&a!==536870912&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,a=Kt.current,me(Kt,m?a&1|2:a&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return ai(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(a&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),a=l.updateQueue,a!==null&&Uu(l,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==a&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),l.memoizedState.cache!==a&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function p4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ft(l),null;case 31:if(l.memoizedState!==null){if(ai(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(ai(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return ai(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:ft(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&ai(l);break;case 13:ai(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:ai(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function ya(i,l){try{var a=l.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var m=d.next;a=m;do{if((a.tag&i)===i){d=void 0;var y=a.create,S=a.inst;d=y(),S.destroy=d}a=a.next}while(a!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,a){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=a,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var a=i.stateNode;try{Fw(l,a)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,a){a.props=Qs(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(d){Nt(i,l,d)}}function ba(i,l){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof a=="function"?i.refCleanup=a(d):a.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var a=i.ref,d=i.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(m){Nt(i,l,m)}else a.current=null}function n2(i){var l=i.type,a=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,a){try{var d=i.stateNode;q4(d,i.type,a,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,l):(l=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,l.appendChild(i),a=a._reactRootContainer,a!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,a),i=i.sibling;i!==null;)qm(i,l,a),i=i.sibling}function Vu(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?a.insertBefore(i,l):a.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vu(i,l,a),i=i.sibling;i!==null;)Vu(i,l,a),i=i.sibling}function r2(i){var l=i.stateNode,a=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,a),l[_t]=i,l[Yt]=a}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,an=null;function m4(i,l){if(i=i.containerInfo,rg=ud,i=yw(i),Op(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var oe;xe!==a||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(oe=xe.firstChild)!==null;)ie=xe,xe=oe;for(;;){if(xe===i)break t;if(ie===a&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(oe=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=oe}a=N===-1||$===-1?null:{start:N,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(sg={focusedElem:i,selectionRange:a},ud=!1,an=l;an!==null;)if(l=an,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,an=i;else for(;an!==null;){switch(l=an,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a title"))),xn(y,d,a),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(a.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(oe.rangeCount!==1||oe.anchorNode!==P.node||oe.anchorOffset!==P.offset||oe.focusNode!==H.node||oe.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),oe.removeAllRanges(),Ye>Et?(oe.addRange(Z),oe.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),oe.addRange(Z))}}}}for(xe=[],oe=N;oe=oe.parentNode;)oe.nodeType===1&&xe.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Na?32:a,q.T=null,a=Fm,Fm=null;var y=ps,S=jr;if(ln=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,a),wt=N,ka(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,a){l=Si(a,l),l=Am(i.stateNode,l,2),i=os(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,a){if(i.tag===3)q2(i,i,a);else for(;l!==null;){if(l.tag===3){q2(l,i,a);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(a,i),a=BS(2),d=os(l,a,2),d!==null&&($S(a,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,a){var d=i.pingCache;if(d===null){d=i.pingCache=new b4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(a)||(Hm=!0,m.add(a),i=A4.bind(null,i,l,a),l.then(i,i))}function A4(i,l,a){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ut&a)===a&&(Ut===4||Ut===3&&(ut&62914560)===ut&&300>ht()-Yu?(wt&2)===0&&Zl(i,0):zm|=a,Ql===ut&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function k4(i){var l=i.memoizedState,a=0;l!==null&&(a=l.retryLane),B2(i,a)}function C4(i,l){var a=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(a=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,a)}function N4(i,l){return We(i,l)}var Zu=null,to=null,Xm=!1,ed=!1,Jm=!1,gs=0;function tr(i){i!==to&&i.next===null&&(to===null?Zu=to=i:to=to.next=i),ed=!0,Xm||(Xm=!0,j4())}function ka(i,l){if(!Jm&&ed){Jm=!0;do for(var a=!1,d=Zu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,z2(d,y))}else y=ut,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(a=!0,z2(d,y));d=d.next}while(a);Jm=!1}}function T4(){$2()}function $2(){ed=Xm=!1;var i=0;gs!==0&&$4()&&(i=gs);for(var l=ht(),a=null,d=Zu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,a===null?Zu=m:a.next=m,m===null&&(to=a)):(a=d,(i!==0||(y&3)!==0)&&(ed=!0)),d=m}ln!==0&&ln!==5||ka(i),gs!==0&&(gs=0)}function I2(i,l){for(var a=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function oA(i,l,a){var d=no;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof a=="string"&&(m+='[crossorigin="'+a+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:a,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function K4(i){Er.D(i),oA("dns-prefetch",i,null)}function G4(i,l){Er.C(i,l),oA("preconnect",i,l)}function X4(i,l,a){Er.L(i,l,a);var d=no;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&a&&a.imageSrcSet?(m+='[imagesrcset="'+vi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(m+='[imagesizes="'+vi(a.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=io(i);break;case"script":y=ro(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&a&&a.imageSrcSet?void 0:i,as:l},a),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(ja(y))||l==="script"&&d.querySelector(Ea(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function J4(i,l){Er.m(i,l);var a=no;if(a&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ro(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),a.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ea(y)))return}d=a.createElement("link"),xn(d,"link",i),Xt(d),a.head.appendChild(d)}}}function Q4(i,l,a){Er.S(i,l,a);var d=no;if(d&&i){var m=fr(d).hoistableStyles,y=io(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(ja(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},a),(a=ji.get(y))&&fg(i,a);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,sd(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function W4(i,l){Er.X(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Z4(i,l){Er.M(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function aA(i,l,a,d){var m=(m=Re.current)?rd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(l=io(a.href),a=fr(m).hoistableStyles,d=a.get(l),d||(d={type:"style",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=io(a.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(ja(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ji.set(i,a),y||eD(m,i,a,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=a.async,a=a.src,typeof a=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ro(a),a=fr(m).hoistableScripts,d=a.get(l),d||(d={type:"script",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function io(i){return'href="'+vi(i)+'"'}function ja(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function eD(i,l,a,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",a),Xt(l),i.head.appendChild(l))}function ro(i){return'[src="'+vi(i)+'"]'}function Ea(i){return"script[async]"+i}function uA(i,l,a){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(a.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),sd(d,a.precedence,i),l.instance=d;case"stylesheet":m=io(a.href);var y=i.querySelector(ja(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(a),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,sd(y,a.precedence,i),l.instance=y;case"script":return y=ro(a.src),(m=i.querySelector(Ea(y)))?(l.instance=m,Xt(m),m):(d=a,(m=ji.get(y))&&(d=b({},a),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,sd(d,a.precedence,i));return l.instance}function sd(i,l,a){for(var d=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function tD(i,l,a){if(a===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function nD(i,l,a,d){if(a.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var m=io(d.href),y=l.querySelector(ja(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=od.bind(i),l.then(i,i)),a.state.loading|=4,a.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),a.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,l),(l=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=od.bind(i),l.addEventListener("load",a),l.addEventListener("error",a))}}var pg=0;function iD(i,l){return i.stylesheets&&i.count===0&&cd(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function od(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ad=null;function cd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ad=new Map,l.forEach(rD,i),ad=null,od.call(i))}function rD(i,l){if(!(l.state.loading&4)){var a=ad.get(i);if(a)var d=a.get(null);else{a=new Map,ad.set(i,a);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),bd.exports=qA(),bd.exports}var $A=BA(),I=Sd();const kd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!o&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(o)?o:[o]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},o)=>I.createElement(VA,{ref:o,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _a=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Cd=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const ao=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Nd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Td=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const La=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const jd=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const Ed=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const co=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Od=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Md=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},qa={},Or={},Pg;function uo(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` -`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` -`,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` -`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentb&&(h=" ... ",o=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(o,c).replace(/\t/g,"→")+g,pos:u-o+h.length}}function n(s,o){return t.repeat(" ",o-s.length)+s}function r(s,o){if(o=Object.create(o||null),!s.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+o.linesAfter,f.length).toString().length,w=o.maxLength-(o.indent+v+3);for(let C=1;C<=o.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",o.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` +`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",o.indent)+n((s.line+1).toString(),v)+" | "+A.str+` +`,b+=t.repeat("-",o.indent+v+3+A.pos)+`^ +`;for(let C=1;C<=o.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",o.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Dd=r,Dd}var _d,Gg;function Mn(){if(Gg)return _d;Gg=1;const t=fo(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(o){const c={};return o!==null&&Object.keys(o).forEach(function(u){o[u].forEach(function(f){c[String(f)]=u})}),c}function s(o,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+o+'" YAML type.')}),this.options=c,this.tag=o,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return _d=s,_d}var Ld,Xg;function Jg(){if(Xg)return Ld;Xg=1;const t=fo(),e=Mn();function n(o,c){const u=[];return o[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(o.multi[u.kind].push(u),o.multi.fallback.push(u)):o[u.kind][u.tag]=o.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function o(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ud}var Vd,d0;function f0(){if(d0)return Vd;d0=1;const t=uo(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function o(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Vd=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:o,predicate:f,represent:u,defaultStyle:"lowercase"}),Vd}var Fd,h0;function p0(){return h0||(h0=1,Fd=r0().extend({implicit:[l0(),a0(),u0(),f0()]})),Fd}var Pd,m0;function g0(){return m0||(m0=1,Pd=p0()),Pd}var Yd,y0;function b0(){if(y0)return Yd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function o(c){return c.toISOString()}return Yd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:o}),Yd}var Kd,x0;function v0(){if(x0)return Kd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Kd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Kd}var Gd,w0;function S0(){if(w0)return Gd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function o(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Gd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:s}),Gd}var Xd,A0;function k0(){if(A0)return Xd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(o){if(o===null)return!0;const c={},u=o;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function ae(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function we(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function bt(x,U,pe){let ue,X,k,V,W,ve;const F=x.kind,de=x.result;let le=x.input.charCodeAt(x.position);if(R(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;le!==0;){if(le===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(le===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&ft(x)||pe&&_(le))break;if(O(le))if(V=x.line,W=x.lineStart,ve=x.lineIndent,$e(x,!1,-1),x.lineIndent>=U){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=ve;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))$e(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const ve=x.anchor;let F,de,le,Ae;const Te=Object.create(null);let je,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&ae(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if($e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=ve,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=je=ze=null,de=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=le=!0,x.position++,$e(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ht(x,U,o,!1,!0),Le=x.tag,je=x.result,$e(x,!0,U),Ve=x.input.charCodeAt(x.position),(le||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),$e(x,!0,U),ht(x,U,o,!1,!0),ze=x.result),Ae?He(x,W,Te,Le,je,ze,ue,X,k):de?W.push(He(x,null,Te,Le,je,ze,ue,X,k)):W.push(je),$e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function Se(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,ve=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` -`,de=we&&(k[k.length-2]===` +`,X?1+W:W),X=!0,k=!0,W=0;const le=x.position;for(;!O(de)&&de!==0;)de=x.input.charCodeAt(++x.position);Ce(x,le,x.position,!1)}return!0}function Ne(x,U){const pe=x.tag,ue=x.anchor,X=[];let k=!1;if(x.firstTabInLine!==-1)return!1;x.anchor!==null&&ae(x,x.anchor,X);let V=x.input.charCodeAt(x.position);for(;V!==0&&(x.firstTabInLine!==-1&&(x.position=x.firstTabInLine,q(x,"tab characters must not be used in indentation")),V===45);){const W=x.input.charCodeAt(x.position+1);if(!R(W))break;if(k=!0,x.position++,$e(x,!0,-1)&&x.lineIndent<=U){X.push(null),V=x.input.charCodeAt(x.position);continue}const ve=x.line;if(ht(x,U,u,!1,!0),X.push(x.result),$e(x,!0,-1),V=x.input.charCodeAt(x.position),(x.line===ve||x.lineIndent>U)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(je&&(X=x.line,k=x.lineStart,V=x.position),ht(x,U,f,!0,ue)&&(je?Ae=x.result:Te=x.result),je||(He(x,F,de,le,Ae,Te,X,k,V),le=Ae=Te=null),$e(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const je=k=V=f===pe||u===pe;if(ue&&$e(x,!0,-1)&&(ve=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&le.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&ae(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&($e(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if($e(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,$e(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),$e(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ft(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,$e(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==o||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==o&&k!==f&&k!==u}function He(k,V,W){const ve=qe(k),F=ve&&!Ce(k);return(W?ve:ve&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==o&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function $e(k){return!Ce(k)&&k!==j}function ft(k,V){const W=k.charCodeAt(V);let ve;return W>=55296&&W<=56319&&V+1=56320&&ve<=57343)?(W-55296)*1024+ve-56320+65536:W}function At(k){return/^\n* /.test(k)}const bt=1,Ge=2,Q=3,re=4,Se=5;function Ne(k,V,W,ve,F,de,le,Ae){let Te,je=0,Le=null,ze=!1,Ve=!1;const Dt=ve!==-1;let Fn=-1,jn=Je(ft(k,0))&&$e(ft(k,k.length-1));if(V||le)for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}else{for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),je===u)ze=!0,Dt&&(Ve=Ve||Te-Fn-1>ve&&k[Fn+1]!==" ",Fn=Te);else if(!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}Ve=Ve||Dt&&Te-Fn-1>ve&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!F(k)?bt:de===we?Se:Ge:W>9&&At(k)?Se:le?de===we?Se:Ge:Ve?re:Q}function Be(k,V,W,ve,F){k.dump=(function(){if(V.length===0)return k.quotingType===we?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===we?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=ve||k.flowLevel>-1&&W>=k.flowLevel;function Te(je){return ne(k,je)}switch(Ne(V,Ae,k.indent,le,Te,k.quotingType,k.forceQuotes&&!ve,F)){case bt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+lt(z(V,de));case re:return">"+We(V,k.indent)+lt(z(ti(V,le),de));case Se:return'"'+ht(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",ve=k[k.length-1]===` +`,de=ve&&(k[k.length-2]===` `||k===` -`)?"+":we?"":"-";return W+de+` -`}function vt(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`)?"+":ve?"":"-";return W+de+` +`}function lt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let ve=(function(){let Ae=k.indexOf(` `);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` -`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` -`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` -`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` -`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` -`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ -`)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); -const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` -`)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` -`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`||k[0]===" ",de,le;for(;le=W.exec(k);){const Ae=le[1],Te=le[2];de=Te[0]===" ",ve+=Ae+(!F&&!de&&Te!==""?` +`:"")+Tn(Te,V),F=de}return ve}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let ve,F=0,de,le=0,Ae=0,Te="";for(;ve=W.exec(k);)Ae=ve.index,Ae-F>V&&(de=le>F?le:Ae,Te+=` +`+k.slice(F,de),F=de+1),le=Ae;return Te+=` +`,k.length-F>V&&le>F?Te+=k.slice(F,le)+` +`+k.slice(le+1):Te+=k.slice(F),Te.slice(1)}function ht(k){let V="",W=0;for(let ve=0;ve=65536?ve+=2:ve++){W=ft(k,ve);const F=ce[W];!F&&Re(W)?(V+=k[ve],W>=65536&&(V+=k[ve+1])):V+=F||ae(W)}return V}function ni(k,V,W){let ve="";const F=k.tag;for(let de=0,le=W.length;de"u"&&U(k,V,null,!1,!1))&&(ve!==""&&(ve+=","+(k.condenseFlow?"":" ")),ve+=k.dump)}k.tag=F,k.dump="["+ve+"]"}function Vn(k,V,W,ve){let F="";const de=k.tag;for(let le=0,Ae=W.length;le"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!ve||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let ve="";const F=k.tag,de=Object.keys(W);for(let le=0,Ae=de.length;le1024&&(Te+="? "),Te+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Te+=k.dump,ve+=Te))}k.tag=F,k.dump="{"+ve+"}"}function kt(k,V,W,ve){let F="";const de=k.tag,le=Object.keys(W);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Te=le.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?je+="?":je+="? "),je+=k.dump,Ve&&(je+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?je+=":":je+=": ",je+=k.dump,F+=je)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const ve=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=ve.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Te}return!0}}return!1}function U(k,V,W,ve,F,de,le){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Te=ve;ve&&(ve=k.flowLevel<0||k.flowLevel>V);const je=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(je&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(je&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")ve&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")ve&&k.dump.length!==0?(k.noArrayIndent&&!le&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&Be(k,k.dump,V,de,Te);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],ve=[];ue(k,W,ve);const F=ve.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const o of r){if(s===null||typeof s!="object"||!(o in s))throw new Error(`Reference not found: ${n}`);s=s[o]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const o=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return o[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:o,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),o?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],tf={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(tf),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function nf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...tf[t]]:Cs.filter(n=>t.some(r=>r===n||tf[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function ho(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(o=>typeof o=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function Ba(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const o={...ho(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete o[e]:o[e]=c,o.expand===void 0&&o.sidebarCollapsed===void 0&&o.theme===void 0&&o.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(o))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],o=e[r]??s?.default;if(o===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(o))throw new Error(`Invalid value for server variable ${r}: ${o}`);return o})}function rf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const o=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of o)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return rf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=rf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const o=r.requestBody,c=o?Object.keys(o.content||{})[0]:void 0;if(c){s.contentType=c;const u=o.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function sf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=sf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,o])=>`${s}=${cn(o)}`).join(","):r.flatMap(([s,o])=>[s,cn(o)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=sf(e),o=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(o);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[o(f),o(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=o(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=sf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([o,c])=>[`${t.name}[${o}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(o=>[t.name,cn(o)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const o=Object.entries(s);return r?o.map(([c,u])=>[c,cn(u)]):[[t.name,o.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,o){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,o))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=o[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=rf(t,e,n),o=s.servers[0],c=r.serverUrl||(o?wk(o,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const o=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)o.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&o.push(` --data-raw ${un(t.body)}`),o.join(` \\ +`)}if(e==="javascript"){const o={method:t.method};return n.length&&(o.headers=t.headers),t.body&&(o.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(o,null,2)}); +const data = await response.json();`}if(e==="python"){const o=["import requests","",`url = ${un(t.url)}`];return n.length&&o.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&o.push(`body = ${un(t.body)}`),o.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),o.join(` +`)}if(e==="go"){const o=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${o})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` +`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[o,c]of n)r.push(` .header(${un(o)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var lf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,o=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=ae.value.length,ae=ae.next){var we=ae.value;if(j.length>O.length)return;if(!(we instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=ae.value.length;Re>=ne;)ae=ae.next,ne+=ae.value.length;if(ne-=ae.value.length,he=ne,ae.value instanceof f)continue;for(var Ce=ae;Ce!==j.tail&&(neM.reach&&(M.reach=$e);var ft=ae.prev;He&&(ft=v(j,ft,He),he+=He.length),w(j,ft,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(ae=v(j,ft,At),Je&&v(j,ae,Je),T>1){var bt={cause:G+","+B,reach:$e};g(O,j,R,ae.prev,he,bt),M&&bt.reach>M.reach&&(M.reach=bt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+o+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(o),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:o=!1})=>{const[c,u]=kd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${o?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:o=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(o.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(o);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:o})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:o},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:o})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:o})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function $a(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),o=Object.keys(r);return s.length===o.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function of(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const o=e(),c=of(o,r),u={key:r,value:String(s),enabled:!0};c>=0?o[c]=u:o.push(u)};return{get(r){const s=of(e(),r);return s>=0?e()[s].value:void 0},has(r){return of(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=$a(t.variables||{}),r=$a(t.collectionVariables||{}),s=$a(t.externalVariables||{}),o=$a(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(o,R)?n[R]=o[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return o[R]},has(R){return Object.prototype.hasOwnProperty.call(o,R)},set(R,_){const L=String(_);o[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete o[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(o,M)?o[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` -`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!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:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,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}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{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 n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.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 fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(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(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(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}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(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,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}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 n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` -`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;se.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",o=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${o}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const o=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>o.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:o}}function cf(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function Ia(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&Ia(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&Ia(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&Ia(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&Ia(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const o=Y0(n);if(o.length>0)throw new Error(`This request requires API host execution (${o.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=cf(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,o])=>({key:s,value:o})),body:t.body,contentType:cf(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:cf(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,o])=>({key:s,value:o,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function po(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const o=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return o&&!("$ref"in o)?o:void 0}function lC(t,e,n,r){const o=rC(t,e,n)?.security??t.security??[];if(!o.length)return;const c=o.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=o.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(o.find(f=>Object.keys(f).length===0)??o[0])}function oC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,o=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:o?.authorizationUrl,tokenUrl:o?.tokenUrl,scopes:n.length?n:Object.keys(o?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function aC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let o=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return o;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return o;if(!h)return{...o,auth:{type:"inherit"}};const g=oC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?o=X0(o,"Authorization"):g.type==="apiKey"&&g.in==="header"?o=X0(o,g.key):g.type==="apiKey"&&g.in==="query"&&(o=aC(o,g.key)),{...o,auth:g}):o}function uC(t,e,n,r,s){const o=B0(t,e,n,r);return{request:cC(t,e,n,r,o),serverUrl:r.serverUrl||s}}function Ha(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const uf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function df(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>df(e.key)?{...e,value:uf}:e)}function fC(t){return t?.map(e=>df(e[0])?[e[0],uf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const o=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return df(g)?`${h}=${encodeURIComponent(uf)}`:u}).join("&");return`${o}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Ha(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",o={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete o.responseBody,delete o.responseBodyTruncated,delete o.requestBodyTruncated),o});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Ha(n.auth)})),folders:t.folders.map(n=>({...n,auth:Ha(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Ha(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function mo(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function za(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function Ua(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!Ua(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Va(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function ff(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(ff(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Va(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(ff(t),JSON.stringify(wC(e))):sessionStorage.removeItem(ff(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(Ua))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(Ua))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(Ua))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Va(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Va(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Va(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const o=r.get(s.parentFolderId);(!o||o.collectionId!==s.collectionId||o.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const o=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(o.has(c)){s.parentFolderId=void 0;break}o.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!za(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!za(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!za(t,"runIndex")||!za(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,o])=>[s,o]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=mo();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function oy(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),o=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:o,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:o,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=o=>{if(o.length<=e)return e-=o.length,o;const c=o.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(o=>({...o,value:r(o.value)}))),s.formData&&(s.formData=s.formData.map(o=>({...o,value:r(o.value)}))),{request:s,truncated:n}}function ay(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),o={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:mo()};return{...t,history:[o,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),o=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!o.has(c.id);){if(o.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function hf(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function pf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),o=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,o=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});o=!0}if(!o)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:mo()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let o=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=o.filter(w=>w.key.trim()!==h);v.length!==o.length&&(o=v,c=!0);continue}const g=o.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];o[v]={...o[v],key:h,value:b,enabled:!0},g.length>1&&(o=o.filter((w,A)=>A===v||w.key.trim()!==h))}else o.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:o,updatedAt:mo()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=mo();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const o=e.transaction(tl,"readonly").objectStore(tl).get(t);o.onsuccess=()=>n(AC(t,oy(o.result))),o.onerror=()=>r(o.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const o=n.transaction(tl,"readwrite");o.objectStore(tl).put(Z0(e),t),o.oncomplete=()=>r(),o.onerror=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace")),o.onabort=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),o=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{o.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,o.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function mf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,o=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:mf(O,.5),p95Ms:mf(O,.95),p99Ms:mf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),o=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:o===null?null:new Date(o).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,o=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const gf=zC();function VC(t){gf.record(t)}function FC(){return gf.snapshot()}function PC(){gf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function yf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=yf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Fa(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,o]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${o}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Pa(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&po(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,o=t.hostExecution?.preferHostExecution,c=o===!1?!1:t.preferHostExecution??s??o??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Pa({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:o}of n){const c=s.file;r.append(`formData[${o}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=yf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let o=yf(t.request),c=Fa(t.variables),u=Fa(t.collectionVariables);const f=Fa(t.externalVariables);let h=Fa(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(o=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(o={...o,auth:t.resolveAuth(o.auth)}),o=nC(o,c),w=(o.method||"GET").toUpperCase(),A=o.url;const[j,,,R]=Pa({request:o,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(o);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(o);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function bf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:o="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":o,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Ya(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const o of e)n+=String.fromCharCode(o);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function oN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),o=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",o),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Ya(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function aN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||aN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const o=vy(48),c=await oN(o);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:o}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,o=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:o,scope:typeof n.scope=="string"?n.scope:void 0}}async function Ka(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},o=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&o?s.Authorization=`Basic ${lN(`${o}:${t.clientSecret||""}`)}`:(o&&e.set("client_id",o),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),o=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-osetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}const s=await cN(t,e.windowObject),o=await dN(s,e);if((o.searchParams.get("state")||new URLSearchParams(o.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(o.hash.replace(/^#/,"")),f=o.searchParams.get("error")||u.get("error");if(f){const b=o.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=o.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Ka(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Ya(t);return s&&r.set("scope",s),Ka(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,o]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{o(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{o(!1)}},w=async()=>{o(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{o(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},xf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:o,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>o(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>o({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:o}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>o({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>o({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>o({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>o({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>o({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>o({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>o({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>o({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>o({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>o({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>o({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>o({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>o({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>o({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>o({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>o({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>o({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>o({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let vf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=wf(t,e);for(e+=jy(r);e=0&&Ay(wf(t,c));)o++,c-=2;if(o%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new go(this),o=new go(e);for(let c=n,u=n;;){if(s.next(c),o.next(c),c=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new go(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.text[o],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let o=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ga(o.text,c.text.slice(),0,o.length);if(u.length<=32)r.push(new Vt(u,c.length+o.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ga(this.text,Ga(r.text,Ey(this.text,0,e)),n),o=this.length+r.length-(n-e);return s.length<=32?new Vt(s,o):Hi.from(Vt.split(s,[]),o)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;o<=n&&ce&&c&&(s+=r),eo&&(s+=u.slice(Math.max(0,e-o),n-o)),o=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let o of e)r.push(o),s+=o.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.children[o],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let o=0,c=0;c<=n&&o=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=o&&n<=u){let f=c.replace(e-o,n-o,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;oe&&o&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,o,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,o+=n){if(s==c||o==u)return r;let f=this.children[s],h=e.children[o];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),o=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>o&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ga(t,e,n=0,r=1e9){for(let s=0,o=0,c=!0;o=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],o=this.offsets[r],c=o>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new go(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},go.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const Sf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return o+(e-s);o+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?o:o+f;o+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Af(this,(n,r,s,o,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return kf(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,o=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,o.text),o.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],o=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||Sf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(o,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,o,g,b),s=h,o=g}}}function kf(t,e,n,r=!1){let s=[],o=r?[]:null,c=new yo(t),u=new yo(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),o.forward2(f),c.forward(f)}}}}class yo{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-o.from),n=e.indexOf(r);for(let s=1;so.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Cf=0;class Ue{constructor(e,n,r,s,o){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=Cf++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Nf),!!e.static,e.enables)}of(e){return new Xa([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Nf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Xa{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=Cf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,o=this.id,c=e[o]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Tf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[o];if(A!=null){let C=Za(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),o=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Ja).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let o=r.values[n],c=this.updateF(o,s);return this.compareF(o,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let o=r.facet(Ja),c=s.facet(Ja),u;return(u=o.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Ja.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function bo(t){return e=>new Ly(e,t)}const Qa={highest:bo(Ns.highest),high:bo(Ns.high),default:bo(Ns.default),low:bo(Ns.low),lowest:bo(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new jf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Wa{constructor(e,n,r,s,o,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=o,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],o=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(o[v.facet.id]||(o[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in o){let w=o[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Nf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Wa(e,c,b,u,f,o)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function o(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof jf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)o(h,u);else if(c instanceof jf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),o(h,u)}else if(c instanceof Ly)o(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&o(c.provides,u);else if(c instanceof Xa)r[u].push(c),c.facet.extensions&&o(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(h,u)}}return o(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function xo(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Za(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),Ef=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let o=s.map(n);o&&r.push(o)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,o,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=o,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),o.some(u=>u.type==rn.time)||(this.annotations=o.concat(rn.time.of(Date.now())))}static create(e,n,r,s,o,c){return new rn(e,n,r,s,o,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let o,c;if(r=t[r]))o=t[r++],c=t[r++];else if(s=0;s--){let o=r[s](t);o instanceof rn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof rn?t=o[0]:t=Vy(e,sl(o),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let o=n[s](t);o&&Object.keys(o).length&&(r=Uy(r,Of(e,o,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Mf;try{Mf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Mf)return Mf.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,o,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let o;n?o=e.startState.values.slice():(n=Wa.resolve(r,s,this),o=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(Ef)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),o=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Wa.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||Sf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(Ef)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(o,c)=>c.create(o),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>n.length?r:n[o-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let o of this.facet(qy))for(let c of o(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(o(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Rf(t,e,n={}){let r={};for(let s of t)for(let o of Object.keys(s)){let c=s[o],u=r[o];if(u===void 0)r[o]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,o))r[o]=n[o](u,c);else throw new Error("Config merge conflict for field "+o)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return _f.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Df(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let _f=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function Lf(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class qf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let o=r?this.to:this.from;for(let c=s,u=o.length;;){if(c==u)return c;let f=c+u>>1,h=o[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let o=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,o);oE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}o(C,E,v)}}return{mapped:c.length?new qf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:o=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(Lf)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new vo;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new vo),o.addRange(f,h,g,!1)};for(let f=0;f=o&&e<=o+c.length&&c.between(o,e-o,n-o,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return wo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return wo.from(e).goto(n)}static compare(e,n,r,s,o=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),f=Fy(c,u,r),h=new So(c,f,o),g=new So(u,f,o);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let o=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(o.length!=c.length)return!1;if(!o.length)return!0;let u=Fy(o,c),f=new So(o,u,0).goto(r),h=new So(c,u,0).goto(r);for(;;){if(f.to!=h.to||!$f(f.active,h.active)||f.point&&(!h.point||!Df(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,o=-1){let c=new So(e,null,o).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new vo;for(let s of e instanceof _f?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(Lf);e=r}return t}mt.empty.nextLayer=mt.empty;class vo{finishChunk(e){this.chunks.push(new qf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new vo)).addRange(e,n,r,s)}addInner(e,n,r,s){let o=e-this.lastTo||r.startSide-this.last.endSide;if(s&&o<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let o of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,o));return s.length==1?s[0]:new wo(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),Bf(this.heap,0)}}}function Bf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class So{constructor(e,n,r){this.minPoint=r,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=wo.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){ec(this.active,e),ec(this.activeTo,e),ec(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:o}=this.cursor;for(;n0;)n++;tc(this.active,n,r),tc(this.activeTo,n,s),tc(this.activeRank,n,o),e&&tc(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&ec(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,o){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!o.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Df(t.point,n.point)&&$f(t.activeForPoint(t.to),n.activeForPoint(n.to))||o.comparePoint(u,A,t.point,n.point),g=!1):(g&&o.boundChange(u),A>u&&!$f(t.active,n.active)&&o.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function $f(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;o+=t.charCodeAt(s)==9?n-o%n:1,s=kn(t,s)}return t.length}const If="ͼ",Gy=typeof Symbol>"u"?"__"+If:Symbol.for(If),Hf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ol{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function o(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))o(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");o(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)o(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,If+e.toString(36)}static mount(e,n,r){let s=e[Hf],o=r&&r.nonce;s?o&&s.setNonce(o):s=new IN(e,o),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let o=Jy.get(r);if(o)return e[Hf]=o;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Hf]=this}mount(e,n){let r=this.sheet,s=0,o=0;for(let c=0;c-1&&(this.modules.splice(f,1),o--,f=-1),f==-1){if(this.modules.splice(o++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Ao[dn]=String.fromCharCode(dn);for(var zf in $r)Ao.hasOwnProperty(zf)||(Ao[zf]=$r[zf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ao:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Uf=typeof document<"u"?document:{documentElement:{style:{}}};const Vf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Ff=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),ic=!!(Qy||Ff||Vf),Wy=!ic&&/gecko\/(\d+)/i.test(Dn.userAgent),Pf=!ic&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in Uf.documentElement.style,Yf=!ic&&/Apple Computer/.test(Dn.vendor),eb=Yf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:ic,ie_version:Qy?Uf.documentMode||6:Ff?+Ff[1]:Vf?+Vf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Pf,chrome_version:Pf?+Pf[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Yf,safari_version:Yf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:Uf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Kf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const rc=Object.create(null);function Gf(t,e,n){if(t==e)return!0;t||(t=rc),e||(e=rc);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let o of r)if(o!=n&&(s.indexOf(o)==-1||t[o]!==e[o]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:o,end:c}=nb(e,n);r=(o?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new Co(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}on.none=mt.empty;class ko extends on{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Kf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||rc}eq(e){return this==e||e instanceof ko&&this.tagName==e.tagName&&Gf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}ko.prototype.point=!1;class Co extends on{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Co&&this.spec.class==e.spec.class&&Gf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Co.prototype.mapMode=Wn.TrackBefore,Co.prototype.point=!0;class js extends on{constructor(e,n,r,s,o,c){super(n,r,o,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function al(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class No extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof No&&this.tagName==e.tagName&&Gf(this.attributes,e.attributes)}static create(e){return new No(e.tagName,e.attributes||rc,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}No.prototype.startSide=No.prototype.endSide=-1;function To(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Xf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function jo(t,e){if(!e.anchorNode)return!1;try{return Xf(t,e.anchorNode)}catch{return!1}}function lc(t){return t.nodeType==3?Oo(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Eo(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function oc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,o,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+o)):e.right>v.right-o&&(E=e.right-v.right+o,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let o=t.parentNode;o&&!(o==n.body||(!e||r)&&s);)if(o.nodeType==1)!s&&o.scrollHeight>o.clientHeight&&(s=o),e&&!r&&o.scrollWidth>o.clientWidth&&(r=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:r,y:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ob(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ab(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ob(e))}let cb;function Oo(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),o.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!oc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(o<0||(s!=0?s<0?u.fromn:e[o].level>u.level))&&(o=c)}}if(o<0)throw new RangeError("Index out of range");return o}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?o:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,o=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else o=h,f++}}}function Wf(t,e,n,r,s,o,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Zf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Wf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>o[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==o[h-1].to){if(b)break e;let C=o[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&o[D-1].to==E)E=o[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Zf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var o;let c=r.head-t.from,u=Vi.find(e,c,(o=r.bidiLevel)!==null&&o!==void 0?o:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,o,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=o,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const cc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(uc.of(h=>{let g=h.plugin(u);return g?c(g):on.none})),o&&f.push(o(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class ih{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),rh=Ue.define(),uc=Ue.define(),Eb=Ue.define(),sh=Ue.define(),Mo=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(o=>o instanceof Function?o(t):o),s=[];return mt.spans(r,e.from,e.to,{point(){},span(o,c,u,f){let h=o-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let o of t.state.facet(Rb)){let c=o(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ro=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(o,c,u,f))),this.changedRanges=s}static create(e,n,r){return new dc(e,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}}const oT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return oT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 hc)return e;return null}static get(e){return e.cmTile}}class fc extends Ht{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 n=this.dom,r=null,s,o=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,o&&s!=u.dom&&(o.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,o&&s&&(o.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hc extends fc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,o=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&o++,s=n.pop()}else{let c=r.children[s++];if(c instanceof or)n.push(s),r=c,s=0;else{let u=o+c.length,f=e(c,o);if(f!==void 0)return f;o=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,o,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,c=e-f)}}),!r&&!o)throw new Error("No tile at position "+e);return r&&n<0||!o?{tile:r,offset:s}:{tile:o,offset:c}}}class or extends fc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new or(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends fc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,o=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,o=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?o:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):aT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:o}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,o)):s.domPosFor(o,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function aT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=lc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let o=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(o--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let o=this.dom.getClientRects(),c=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;c=o[f],!(e>0?f==0:f==o.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:o,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(o==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:o}=u.pop(),o++}else{let f=s.children[o],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(lh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(lh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let o=Ht.get(e.text);o&&this.cache.reused.set(o,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let o=this.ensureMarks(n,r);!s&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let o=e.length-1;o>=0;o--){let c=e[o],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(oh,0,32)||new Rs(oh.toDOM(),0,oh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(o),n=o}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(pc,void 0,1);return r&&(r.flags=n),r||new pc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:o,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return o?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const mc=[Rs,fl,Ms,Hn,pc,or,hc];for(let t=0;t[]),this.index=mc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,o=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,o=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,o+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=o=0):c instanceof Hn&&(s.shift(),o=Math.min(o,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,o=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>o),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let o=Ht.get(s);if(s==this.view.contentDOM)break;o instanceof Hn?n.push(o):o?.isLine()?r=o:o instanceof or||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new ko({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Kf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function lh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends sc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const oh=new class extends sc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=on.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 hc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let o=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Oe.ie||Oe.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),o&&!r.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(r=o.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 o=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||r.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&jo(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(o||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!Eo(h.node,h.offset,b.anchorNode,b.anchorOffset)||!Eo(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=To(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=To(e.root),{anchorNode:s,anchorOffset:o}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,o)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let o;if(e==r.dom)o=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?o=e:o=e.nextSibling}if(o==r.dom.firstChild)return s;for(;o&&!Ht.get(o);)o=o.nextSibling;if(!o)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,o=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(o=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,o=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(o&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:o}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof ch?null:s.coordsInWidget(o,n,!0):s.coordsIn(o,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(o,c){if(o.isComposite())for(let u of o.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(o.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof or)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?lc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=o,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=lc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,o;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=lc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,o=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:o}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let o=s==n.viewports.length?null:n.viewports[s],c=o?o.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(on.replace({widget:new ch(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!o)break;r=o.to+1}return on.set(e)}updateDeco(){let e=1,n=this.view.state.facet(uc).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),r=!1,s=this.view.state.facet(sh).map((o,c)=>{let u=typeof o=="function";return u&&(r=!0),u?o(this.view):o});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Db(this.view),c={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),o=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=r,!o)return null;let c=e-o.offset;return{from:c,to:c+o.node.nodeValue.length,node:o.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:o,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(o),f.mapPos(c),o,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class ch extends sc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(s.length==0)return ke.cursor(e);o==0?n=1:o==s.length&&(n=-1);let c=o,u=o;n<0?c=kn(s.text,o,!1):u=kn(s.text,o);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);o+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,o,t.state.tabSize)}function uh(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let o of r.type){if(o.from>e)break;if(!(o.toe)return o;(!s||o.type==fn.Text&&(s.type!=o.type||(n<0?o.frome)))&&(s=o)}}return s||r}return r}function OT(t,e,n,r){let s=uh(t,e.head,e.assoc||-1),o=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(o){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(o.top+o.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,o,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),o=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return o=>{let c=r(o);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,o=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=o<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(o<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*o,E=fh(t,{x:b,y:C},!1,o);if(n?C>f.bottom:Cu:O{if(e>o&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+o:v.bottom>=f+o))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=o&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let o=0;o{let c=r[o]-n,u=r[o+1]-n;return Oo(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Oo(f.dom,0,f.length)).getClientRects()}),o=e.children[s.i],c=r[s.i];return o.isText()?this.scanText(o,c):o.isComposite()?this.scanTile(o,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let o=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:oc(s))||oc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>o)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,c=1,u;if(this.lineSeparator?(o=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(o=u.index,c=u[0].length),this.append(n.slice(r,o<0?n.length:o)),o<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=o+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:o,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=o||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!Xf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Xf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,o=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,o=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:o,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,o=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=o.from,g=null;(c===8||Oe.android&&e.text.length=u&&o.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&b.slice(o.to-u)==e.text.slice(v=e.text.length-(b.length-(o.to-u)))?n={from:o.from,to:o.to,insert:gt.of(e.text.slice(o.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||gc(r,o))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(o.from).toDate.now()-50?n={from:o.from,to:o.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:o.from,to:o.to,insert:gt.of([" "])}),n)return hh(t,n,r,c);if(r&&!gc(r,o)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Mo).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function hh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,o,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,o=s.selection.main,c=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=o.frome.to?s.sliceDoc(e.to,o.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(o.head);let w=o.to-e.to;r=s.changeByRange(A=>{if(A.from==o.from&&A.to==o.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-o.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),o=0;for(;o0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,o-Math.min(c,u));n-=c+f-o}if(c=c?o-n:0;o-=f,u=o+(u-c),c=o}else if(u=u?o-n:0;o-=f,c=o+(c-u),u=o}return{from:o,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||o!=r)&&e.push(new zb(s,o))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function gc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let o in n)if(o!="scroll"){let c=!n[o].handlers.length,u=r[o];u&&c!=!u.handlers.length&&(s.removeEventListener(o,this.handleEvent),u=null),u||s.addEventListener(o,this.handleEvent,{passive:c})}for(let o in r)o!="scroll"&&!n[o]&&s.removeEventListener(o,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,o=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],yc=6;function bc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Mo).map(c=>c(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,o=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+yc?n=-bc(s-e.clientX):e.clientX+f.right>=c-yc&&(n=bc(e.clientX-c)),e.clientY-f.top<=o+yc?r=-bc(o-e.clientY):e.clientY+f.bottom>=u-yc&&(r=bc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=To(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function xc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=xc(t.state,th,e);let{state:n}=t,r,s=1,o=n.toText(e),c=o.lines==n.selection.ranges.length;if(ph!=null&&n.selection.ranges.every(f=>f.empty)&&ph==o.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?o.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=o.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(o);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ab(t.contentDOM);let o=t.root.activeElement;o&&!o.contains(t.contentDOM)&&o.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),o=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:o.from,u=s?s.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(o){o.docChanged&&(n.pos=o.changes.mapPos(n.pos),s=s.map(o.changes))},get(o,c,u){let f=t.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let o=s.posAtStart,c=o+s.length;(o>=n.to||c<=n.from)&&(n=ke.undirectionalRange(o,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",xc(t.state,nh,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=xc(t.state,th,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,c=r&&o&>(t,e)?{from:o.from,to:o.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,o=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),o()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let c=t.doc.lineAt(o);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:xc(t,nh,e.join(t.lineBreak)),ranges:n,linewise:r}}let ph=null;Mi.copy=Mi.cut=(t,e)=>{if(!jo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;ph=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=Gb?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let o=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(o&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return hh(t,{from:f,to:h,insert:t.state.toText(o)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(o=>o.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>o+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ox(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=o,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>vc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let o=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=o.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:o.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fo*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(o>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,o-=u.size}else break;else if(s=o&&c(this.lineAt(0,Rt.ByPos,r,s,o))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ax{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,o=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);c=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else c=this.height/o;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:o,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let o=r[r.length-1];o instanceof hn?r[r.length-1]=new hn(o.length+s):r.push(null,new hn(s-1))}if(e>0){let o=r[0];o instanceof hn?r[0]=new hn(e+o.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let o=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=o&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=vc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=o&&c.push(null,new hn(o-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=vc||Math.abs(f-this.heightMetrics(e,n).perLine)>=vc)&&(ml=!0),wc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class oj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let o=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,o).join(h)}forEachLine(e,n,r,s,o,c){let u=s+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,o);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let o=[];e>0&&this.decomposeLeft(e,o);let c=o.length;for(let u of r)o.push(u);if(e>0&&cx(o,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=wc(this.left,e),this.right=wc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:o,right:c}=this,u=n+o.length+this.break,f=null;return s&&s.from<=n+o.length&&s.more?f=o=o.updateHeight(e,n,r,s):o.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(o,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const aj=5;class mh{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=aj)&&this.addLineDeco(s,o,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();o=Math.max(o,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:o-n.left,right:Math.max(o,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class gh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=on.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:o,to:c})=>s>=o&&s<=c)){let{from:o,to:c}=this.lineBlockAt(s);e.push(new Sc(o,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new yh(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(_o(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,o=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ox(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,o=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(o,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ox();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,o=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new Sc(s.lineAt(c-r*1e3,Rt.ByHeight,o,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,o,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,o,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&o>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new gh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(o,c){r.push({from:o,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||_o(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||_o(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return _o(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}}class Sc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,o=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),o+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:o,to:c}=e[s],u=c-o;if(r<=u)return o+r;r-=u}}function kc(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(uc).filter(r=>typeof r!="function"),n=t.facet(sh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class yh{constructor(e,n,r){let s=0,o=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-o)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),o=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let o=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function _o(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>_o(s,e)):t._content)}const Cc=Ue.define({combine:t=>t.join(" ")}),bh=Ue.define({combine:t=>t.indexOf(!0)>-1}),xh=ol.newName(),hx=ol.newName(),px=ol.newName(),mx={"&light":"."+hx,"&dark":"."+px};function vh(t,e,n){return new ol(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=vh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),wh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!jo(this.dom,s))return;let o=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&Eo(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=To(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=jo(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&cl(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let o of e){let c=this.readMutation(o);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&jo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!gc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return Eo(c.node,c.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:o,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&othis.to&&(f=o);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));gc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);hh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],o=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let o of r.getTextFormats()){let c=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),h=this.toEditorPos(o.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=To(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((o,c,u,f,h)=>{if(r)return;let g=h.length-(c-o);if(s&&c>=s.to)if(s.from==o&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(o+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(othis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(o=>r(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(cc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new ih(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,o=this.state;for(let v of e){if(v.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=v.state}if(this.destroyed){this.viewState.state=o;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(o,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(g=null)):this.observer.clear(),o.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(o);s=dc.create(this,o,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(cc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Nc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Cc)!=s.state.facet(Cc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(eh))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new ih(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let o of r){let c=n.indexOf(o);if(c<0)s.push(new ih(o));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))o=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);o=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=dc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?o<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(eh))f(n)}get themeClasses(){return xh+" "+(this.state.facet(bh)?px:hx)+" "+this.state.facet(Cc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,rh,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),o=tb(this.dom,this.editorAttrs,e);return s||o});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let e=this.state.facet(Xe.cspNonce);ol.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return dh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return dh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),o=r[n?r.length-1:0];return ke.cursor(o.side(n,s)+e.from,o.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return dh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=fh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),fh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,o.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==n&&(o.fresh||mb(o.isolates,r=Mb(this,e))))return o.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Nc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(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,n={}){var r,s,o,c;return cc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(o=n.yMargin)!==null&&o!==void 0?o:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return cc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=ol.newName(),s=[Cc.of(r),Ro.of(vh(`.${r}`,e))];return n&&n.dark&&s.push(bh.of(!0)),s}static baseTheme(e){return Qa.lowest(Ro.of(vh("."+xh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ro,Xe.inputHandler=Sb,Xe.clipboardInputFilter=th,Xe.clipboardOutputFilter=nh,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=eh,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=uc,Xe.blockWrappers=Eb,Xe.outerDecorations=sh,Xe.atomicRanges=Mo,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=bh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=rh,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Nc{constructor(e,n,r,s,o,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=o,this.order=c}static update(e,n){if(n.empty&&!e.some(o=>o.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let o=Math.max(0,e.length-10);o=0;s--){let o=r[s],c=typeof o=="function"?o(t):o;c&&Kf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,o,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},o=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,Sh))}let f=c[e]||c.key;if(f)for(let h of u)o(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&o(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let Sh=null;function Ej(t,e,n,r){Sh=e;let s=UN(e),o=kN(s,0),c=CN(o)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Tc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Tc(A,e,!0)])||e.shiftKey&&(C=Ao[e.keyCode])!=s&&C!=A&&v(w[u+Tc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Tc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),Sh=null,f}class Ds{constructor(e,n,r,s,o){this.className=e,this.left=n,this.top=r,this.width=s,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let o=Sx(e);return[new Ds(n,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let o=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:o.left+1,y:c}),f=t.posAtCoords({x:o.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),o=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=uh(t,r,1),A=uh(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;we>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(we,q),L==null&&we>=be,ae.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(jc)!=e.state.facet(jc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(jc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const jc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),jc.of(t)]}const gl=Ue.define({combine(t){return Rf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(o&&Oe.ios&&n.iosSelectionHandles)){let c=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let o of Ds.forRange(t,"cm-selectionBackground",s))e.push(o);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Qa.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=on.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return on.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const Ec=Ue.define(),Hj=Ue.define(),Oc=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Oc).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Ec),this.view.viewport.from),r=[],s=this.gutters.map(o=>new Vj(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let c=!0;for(let u of o.type)if(u.type==fn.Text&&c){Ah(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(o.type==fn.Text){Ah(n,r,o.from);for(let c of s)c.line(this.view,o,r)}else if(o.widget)for(let c of s)c.widget(this.view,o);for(let o of s)o.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Oc),n=t.state.facet(Oc),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Ec),t.state.facet(Ec),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let o of n){let c=e.indexOf(o);c<0?s.push(new Ox(this.view,o)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let o of this.gutters)o.dom.remove(),s.indexOf(o)<0&&o.destroy();for(let o of s)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Ah(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,o=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,o,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,o,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Ah(this.cursor,s,n.from),r.length&&(s=s.concat(r));let o=this.gutter.config.lineMarker(e,n,s);o&&s.unshift(o);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let o of e.state.facet(Hj)){let c=o(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let o=s.target,c;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let o=0,c=0;;){let u=c,f=oo(u,f,h)||c(u,f,h):c}return r}})}});class kh extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ch(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Oc.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new kh(Ch(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let o=s(e,n,r);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new kh(Ch(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=Ch(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new kh(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Nh{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class Lo{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(s)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return s}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 n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),o=-1;o<(s?s.length:0);o++){let c=n[o<0?r.name:s[o]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Mc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,o){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,o&&o.length){this.props=Object.create(null);for(let[c,u]of o)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=Lo.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Eh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Mc.get(this)||this.topNode,o=new Eh(s);return o.moveTo(e,n),Mc.set(this,o._tree),o}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=qo(Mc.get(this)||this.topNode,e,n,!1);return Mc.set(this,r),r}resolveInner(e,n=0){let r=qo(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:o=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=o&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Mh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Th{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Th(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,o=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function qo(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(o&Pt.EnterBracketed&&g instanceof pn&&(v=Lo.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(o&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(o&Pt.IncludeAnonymous||!g.type.isAnonymous||Oh(g)){let w;if(!(o&Pt.IgnoreMounts)&&(w=Lo.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return o&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,o)}}}if(o&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=Lo.get(this._tree))&&s.overlay){let o=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=o:u=o:f>o))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return o}for(;;){if(r!=null&&s.type.is(r))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return r==null?o:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,o=r.buffer[this.index+3];if(o>s){let c=r.buffer[this.index+1];e.push(r.slice(s,o,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let o=1;on.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+o.from,-1,o);(s||(s=[r])).push(qo(u,e,n,!1))}}return s?Ix(s):r}class Eh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let o=n+e,c=e<0?-1:r._tree.children.length;o!=c;o+=e){let u=r._tree.children[o];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Oh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=o+1;break e}s=this.stack[--o]}for(let s=r;s=0;o--){if(o<0)return jh(this._tree,e,s);let c=r[n.buffer[this.stack[o]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Oh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Oh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:o=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Th(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=o[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],ae,he,we=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);ae=new Ur(T,be-he.start,r),we=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);ae=Mh(J,z,me,0,z.length,0,be-ee,qe,qe)}else ae=C(J,z,me,be-ee,ge-be,q)}M.push(ae),G.push(we)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(yt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[yt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[yt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Rc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Rc(t,r)}Hx.set(e,n)}return n}function Mh(t,e,n,r,s,o,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Mh(t,A,C,R,j,_,M,null,f))}v.push(_+O-o)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,o=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(o?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let o of n)o.to>e.length&&s.push(o);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],o=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=onew Nh(s.from,s.to)):[new Nh(0,0)]:[new Nh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let o=s.advance();if(o)return o}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let o of n.set)s.set.push(o);return s}static defineModifier(e){let n=new Dc(e);return r=>r.modified.indexOf(n)>-1?r:Dc.get(r.base||r,r.modified.concat(n).sort((s,o)=>s.id-o.id))}}let lE=0;class Dc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&oE(n,u.modified));if(r)return r;let s=[],o=new yi(e.name,s,e,n);for(let u of n)u.instances.push(o);let c=aE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Dc.get(u,f));return o}}function oE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function aE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let o=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(o.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=o.length-1,h=o[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new _c(r,c,f>0?o.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let o=new _c(s.tags,s.mode,s.context);n?n.next=o:r=o,n=o}return r}});class _c{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of o)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const Ee=yi.define,Lc=Ee(),Fr=Ee(),zx=Ee(Fr),Ux=Ee(Fr),Pr=Ee(),qc=Ee(Pr),Rh=Ee(Pr),Yi=Ee(),Ls=Ee(Yi),Ki=Ee(),Gi=Ee(),Dh=Ee(),Bo=Ee(Dh),Bc=Ee(),rt={comment:Lc,lineComment:Ee(Lc),blockComment:Ee(Lc),docComment:Ee(Lc),name:Fr,variableName:Ee(Fr),typeName:zx,tagName:Ee(zx),propertyName:Ux,attributeName:Ee(Ux),className:Ee(Fr),labelName:Ee(Fr),namespace:Ee(Fr),macroName:Ee(Fr),literal:Pr,string:qc,docString:Ee(qc),character:Ee(qc),attributeValue:Ee(qc),number:Rh,integer:Ee(Rh),float:Ee(Rh),bool:Ee(Pr),regexp:Ee(Pr),escape:Ee(Pr),color:Ee(Pr),url:Ee(Pr),keyword:Ki,self:Ee(Ki),null:Ee(Ki),atom:Ee(Ki),unit:Ee(Ki),modifier:Ee(Ki),operatorKeyword:Ee(Ki),controlKeyword:Ee(Ki),definitionKeyword:Ee(Ki),moduleKeyword:Ee(Ki),operator:Gi,derefOperator:Ee(Gi),arithmeticOperator:Ee(Gi),logicOperator:Ee(Gi),bitwiseOperator:Ee(Gi),compareOperator:Ee(Gi),updateOperator:Ee(Gi),definitionOperator:Ee(Gi),typeOperator:Ee(Gi),controlOperator:Ee(Gi),punctuation:Dh,separator:Ee(Dh),bracket:Bo,angleBracket:Ee(Bo),squareBracket:Ee(Bo),paren:Ee(Bo),brace:Ee(Bo),content:Yi,heading:Ls,heading1:Ee(Ls),heading2:Ee(Ls),heading3:Ee(Ls),heading4:Ee(Ls),heading5:Ee(Ls),heading6:Ee(Ls),contentSeparator:Ee(Yi),list:Ee(Yi),quote:Ee(Yi),emphasis:Ee(Yi),strong:Ee(Yi),link:Ee(Yi),monospace:Ee(Yi),strikethrough:Ee(Yi),inserted:Ee(),deleted:Ee(),changed:Ee(),invalid:Ee(),meta:Bc,documentMeta:Ee(Bc),annotation:Ee(Bc),processingInstruction:Ee(Bc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var _h;const $c=new yt,fE=new yt;class ar{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((o,c,u)=>{let f=Vx(o,c,u),h=f.type.prop($c);if(!h)return[];let g=o.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,o)){let A=o.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop($c)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(o,c)=>{if(o.prop($c)==this.data){r.push({from:c,to:c+o.length});return}let u=o.prop(yt.mounted);if(u){if(u.tree.prop($c)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+o.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let $o=null;class Ic{constructor(e,n,r=[],s,o,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=o,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Ic(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=$o;$o=this;try{return e()}finally{$o=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:o,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,o=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let o=s[0].from,c=s[s.length-1].to;return{parsedPos:o,advance(){let f=$o;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return $o}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Ic.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}ar.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(ar.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Lh=typeof navigator<"u"&&(!((_h=navigator.scheduling)===null||_h===void 0)&&_h.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=o.context.work(()=>Lh&&Lh()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ar.setState.of(new bl(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[ar.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),qh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Hc(t){let e=t.facet(qh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function zc(t,e){let n="",r=t.tabSize,s=t.facet(qh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let o=0;o=e?yE(t,n,e):null}class Uc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Hc(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:o}=this.options;return s!=null&&s>=r.from&&s<=r.to?o&&s==e?{text:"",from:e}:(n<0?s-1&&(o+=c-this.countColumn(r,r.search(/\S|$/))),o}countColumn(e,n=e.length){return nc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),o=this.options.overrideIndentation;if(o){let c=o(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let o=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)o.push(c);for(let c=o.length-1;c>=0;c--)r={node:o[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(Bh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,o=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,o&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class Bh extends Uc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Bh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(n.from),c=s==null||s<=o.from?o.to:Math.min(o.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let o=t.textAfter,c=o.match(/^\s*/)[0].length,u=r&&o.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function $h(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function Ih(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,o=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=$h(f.type,n,o);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,o)}}return jE(t,e,n,c,u.type,s,o)}function TE(t,e,n,r,s,o,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&o.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=o;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Hh(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Hh(h,`Modifier ${h} used at start of tag`):f.length?Hh(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Hh(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),o=Jx[s];if(o)return o.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Uh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function zh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=zh($E,0),_E=zh(Qx,0),LE=zh((t,e)=>Qx(t,e,BE(e)),0);function Uh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Io=50;function qE(t,{open:e,close:n},r,s){let o=t.sliceDoc(r-Io,r),c=t.sliceDoc(s,s+Io),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(c)[0].length,h=o.length-u;if(o.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*Io?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+Io),b=t.sliceDoc(s-Io,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(o=>Uh(e,o.from).block);if(!r.every(o=>o))return null;let s=n.map((o,c)=>qE(e,r[c],o.from,o.to));if(t!=2&&!s.every(o=>o))return{changes:e.changes(n.map((o,c)=>s[c]?[]:[{from:o.from,insert:r[c].open+" "},{from:o.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(o=>o)){let o=[];for(let c=0,u;cs&&(o==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;vo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&o.push({from:u.from+h,insert:f+" "});let c=e.changes(o);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,o.push({from:h,to:g})}return{changes:o}}return null}const Vh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Rf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Vh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Fc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return o?t=t.addChanges(o,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Fh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Vc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let o=s.pop(t,n,e);return o?(r(o),!0):!1}}const ev=Vc(0,!1),Fh=Vc(1,!1),UE=Vc(0,!0),VE=Vc(1,!0);class zn{constructor(e,n,r,s,o){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=o}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let o=s(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Fc(t,e,n,r){let s=e+1>n+20?e-n-1:0,o=t.slice(s,e);return o.push(r),o}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,o)=>n.push(s,o)),e.iterChangedRanges((s,o,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Fc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Ph(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let o=t.slice(0,n);return o[n-1]=s,o}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(o):o;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(o),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,o){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Pc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function ov(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Pc(n,e))}const JE=t=>ov(t,!Nn(t)),QE=t=>ov(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let o=r.type.prop(s),c,u;return o&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Yc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Yc(t.state,e,Nn(t)));function av(t,e){return _i(t,n=>{if(!n.empty)return Pc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>av(t,!1),uv=t=>av(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Pc(c,e));if(s.eq(r.selection))return!1;let o;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Yh=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(s=ke.cursor(r.from+o))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function oO(t,e,n){let r=!1,s=wl(t.selection,o=>{let c=vl(t,o.head,-1)||vl(t,o.head,1)||o.head>0&&vl(t,o.head-1,1)||o.headoO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let o=n(s);return ke.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Yc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Yc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Gc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),o=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let o of n.selection.ranges){let c=n.doc.lineAt(o.head);if(e?c.to0)for(let u=o;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ho(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(o=>{let{from:c,to:u}=o;if(c==u){let f=e(o);fc&&(n="delete.forward",f=Kc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Kc(t,c,!1),u=Kc(t,u,!0);return c==u?{range:o}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,o)=>{se&&(e=n?o:s)});return e}const Ev=(t,e,n)=>Ho(t,r=>{let s=r.from,{state:o}=t,c=o.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ho(t,n=>{let r=n.head,{state:s}=t,o=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?o.to:o.from)){r==n.head&&o.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(o.text,r-o.from,e)+o.from,h=o.text.slice(Math.min(r,f)-o.from,Math.max(r,f)-o.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ho(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headHo(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ho(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,o=t.doc.lineAt(s),c=s==o.from?s-1:kn(o.text,s-o.from,!1)+o.from,u=s==o.to?s+1:kn(o.text,s-o.from,!0)+o.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=o.to,c.ranges.push(r)}else e.push({from:s.from,to:o.to,ranges:[r]});n=o.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let o of Gc(t)){if(n?o.to==t.doc.length:o.from==0)continue;let c=t.doc.lineAt(n?o.to+1:o.from-1),u=c.length+1;if(n){r.push({from:o.to,to:c.to},{from:o.from,insert:c.text+t.lineBreak});for(let f of o.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:o.from},{from:o.to,insert:t.lineBreak+c.text});for(let f of o.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let o of Gc(t))n?r.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):r.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Gc(e).map(({from:s,to:o})=>(s>0?s--:o{let o;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(o=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,o)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),o;return r&&s&&r.to<=e&&s.from>=e&&(o=r.type.prop(yt.closedBy))&&o.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:o,to:c}=s,u=e.doc.lineAt(o),f=!t&&o==c&&qO(e,o);t&&(o=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new Uc(e,{simulateBreak:o,simulateDoubleBreak:!!f}),g=Yx(h,o);for(g==null&&(g=nc(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));cu.from&&o{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let o=t.changes(s);return{changes:s,range:ke.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Uc(t,{overrideIndentation:o=>{let c=n[o];return c??-1}}),s=Gh(t,(o,c,u)=>{let f=Yx(r,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let h=/^\s*/.exec(o.text)[0],g=zc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(qh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let o=nc(s,t.tabSize),c=0,u=zc(t,Math.max(0,o-Hc(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Kh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Yh}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Yh,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Yh,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Kh,shift:Kh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:aO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:o}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),o!==void 0&&(c["aria-expanded"]=String(o)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const zo=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:o=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,ae=J)=>{const he=O.current;if(!he)return;const we=he.state.doc.length,T=Math.max(0,Math.min(J,we)),z=Math.max(0,Math.min(ae,we));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const ae=O.current;if(!ae)return null;const he=Math.max(0,Math.min(J,ae.state.doc.length)),we=ae.coordsAtPos(he);return we?{left:we.left,right:we.right,top:we.top,bottom:we.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,ae=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Qa.highest(Xe.domEventHandlers({keydown:we=>(_.current?.(we),we.defaultPrevented)})),Xe.updateListener.of(we=>{we.docChanged&&!L.current&&j.current(we.state.doc.toString()),(we.selectionSet||we.docChanged)&&R.current?.(we.state.selection.main.head)})]}),he=new Xe({state:ae,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const ae=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(ae.anchor,e.length),head:Math.min(ae.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(o,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});zo.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Xh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(o,c)=>n(e.map((u,f)=>f===o?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((o,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:o.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:o.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:o.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||po(t),s=n==="dark",o=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Xh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(zo,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:o,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Xh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${o}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${o}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Xh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${o}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(zo,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(zo,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const o=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,o]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>o(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>o("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} -});`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;a{const u=a.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` +`).map(o=>{const u=o.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` `)}function Pv(t,e){return t.slice(0,Math.max(0,Math.min(e,t.length))).replace(/\r\n?/g,` `).length}function Yv(t,e,n){const r=t.split(` `),s=e.split(` -`),a=t.slice(0,Math.max(0,Math.min(n,t.length))),c=a.split(` -`).length-1,u=a.lastIndexOf(` -`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),o=t.slice(0,Math.max(0,Math.min(n,t.length))),c=o.split(` +`).length-1,u=o.lastIndexOf(` +`),f=o.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),o=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(o,s.length),selectionEnd:Math.min(Math.max(o,c),s.length)}}const Jh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Jh,"flex.collection":Jh,"flex.variables":Jh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,o)=>s.localeCompare(o)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,o]of r){const c=n.match(s);if(c)return{path:o,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function o3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function a3(t,e,n,r={},s=!1){const o=Math.max(0,Math.min(e,t.length)),c=t.slice(0,o),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:o-u.prefix.length,to:o,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:o-f.prefix.length,to:o,items:v}:null}const h=o3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:o-h.prefix.length,to:o,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:o-g.length,to:o,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:o={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,ae=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,ae))})},j=(B,K,ee=!1)=>{const be=a3(B,K,r,o,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(ao,{className:"h-3.5 w-3.5"}):p.jsx(Od,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(zo,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Xc="API-host execute route",Jc="the execute path";function Qc(t,e){return`${Xc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Qc("was unauthorized",`documentation authentication for ${Jc}`):t===403?Qc("was rejected",`CSRF, same-origin, and authorization middleware for ${Jc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Xc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Xc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Jc}.`:Qc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const o=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await o.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return o.status===429||o.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):o.redirected?Qc("was redirected",`authentication middleware for ${Jc}`):o.ok?`${Xc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(o.status,o.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Qh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Qh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Qh(n);if(!r)return t;const s=Qh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const o=new URL(t),c=`${o.pathname==="/"?"":o.pathname}${o.search}${o.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||po(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:o}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${o}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${o}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),o=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:o}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:o="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",ae=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",we=J||ae||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(ae),[qe,He]=I.useState(he),Je=I.useRef(we),$e=I.useRef(we),[ft,At]=I.useState(null),[bt,Ge]=I.useState(),[Q,re]=I.useState(null),[Se,Ne]=I.useState(null),[Be,We]=I.useState([]),[lt,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),ve=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Te=["GET","HEAD"].includes(Ae),je=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${je}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&o!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Fo=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=po(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Fo},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>o==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${le}-script-tab-${se}`,En=se=>`${le}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&o!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),ve.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Po=E?E(T.auth):T.auth,Qr=Pa({request:{...T,auth:Po},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),lu=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(ft,{...T,auth:Po},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ht(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Be.filter(se=>se.passed).length,Yo=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Yo&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${je}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||$e.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${je}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{ve.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Te&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:je,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:je,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(xf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:o==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>lu(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),o==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${je}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),o==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${je}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(bf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Yo,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(co,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),Se&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Se]}),ft&&p.jsx(QO,{response:ft,theme:s,curlCommand:bt,advanced:o==="advanced"}),Be.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Be.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Be.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),lt.length>0&&p.jsx(Rr,{code:lt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Wh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:o,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(o,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(o||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>hf(K),[K]),ae=t1(D,_)!==t1(w.request,A),he=C==="advanced",we=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Wh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(bf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${we}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&ae&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(La,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${we}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Wh("tab",ne)},onScriptTabChange:ne=>{B(ne),Wh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>pf(Ce,ne))})]})};function Wc(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(t){if(!t)return"";try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"?e.origin:""}catch{return""}}function T3(t,e,n,r){const s=e.startsWith("/")?e:`/${e}`;return{method:t.toUpperCase(),url:n?`${n}${s}`:s,auth:{type:"none"},...r?{hostExecution:{preferHostExecution:!0}}:{}}}function j3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function E3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const O3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:o,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=j3(),h=o??nf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L){if(!(c?.runtimeOnly?.some(lt=>lt.path===e&<.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(lt=>lt.code==="runtime.operation-undocumented"&<.location.path===e&<.location.method?.toUpperCase()===n.toUpperCase())))return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const Se=N3(c?.serverOrigin),Ne=s.tryIt?.hostExecution,Be=Ne?.available===!0&&Ne.preferHostExecution!==!1,We=()=>u?.({request:T3(n,e,Se,Be),serverUrl:Se||void 0,scripts:{preRequest:"",tests:""},requestTab:"params",scriptTab:"pre-request"});return p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsxs("dl",{className:`mt-4 space-y-3 text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:[p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.contractEvidence||"Contract"}),p.jsx("dd",{children:ce?.contractNotDeclared||"OpenAPI does not declare this operation."})]}),p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.runtimeEvidence||"Runtime"}),p.jsx("dd",{children:ce?.runtimeRouteUndocumented||`${n.toUpperCase()} ${e} is registered by the running service.`})]})]}),u&&p.jsxs("button",{type:"button",className:"mt-4 inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:We,children:[p.jsx(La,{className:"h-4 w-4"}),ce?.openApiClient||"Open in API Client"]})]})}if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",ae=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,we={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const Se=!A.has(re);w(Ne=>{const Be=new Set(Ne.key===b?Ne.sections:g);return Be.has(re)?Be.delete(re):Be.add(re),{key:b,sections:Be}}),re==="tryIt"&&E3("tryIt",Se?"1":void 0)},He=(re,Se,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Se}-heading`,children:[p.jsxs("button",{type:"button",id:`${Se}-heading`,"aria-expanded":A.has(Se),onClick:()=>qe(Se),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Se)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(Se)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},$e=(re,Se)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=ae.indexOf(Se),Be=re.key==="Home"?ae[0]:re.key==="End"?ae[ae.length-1]:re.key==="ArrowRight"?ae[(Ne+1)%ae.length]:ae[(Ne-1+ae.length)%ae.length];Je(Be)},ft=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wc(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,bt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{ft()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Cd,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&bt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:bt.map(([re,Se])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof Se=="string"?Se:JSON.stringify(Se)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...we})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,Se])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),Se.schema&&p.jsx(Dr,{spec:t,schema:Se.schema,theme:r,...we}),Se.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Se.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,Se])=>{const Ne=In.isReference(Se)?In.resolveReference(t,Se.$ref):Se;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([Be,We])=>{const lt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:Be}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...we})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),lt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(lt.value??lt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Be)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:ae.map(re=>p.jsx("button",{ref:Se=>{R.current[re]=Se},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:Se=>$e(Se,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function M3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function R3(t,e){let n=M3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function D3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const o of In.getHttpMethods(s)){const c=s[o];n.push({path:r,method:o,operation:c,score:R3(c,o),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const _3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",o=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=D3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:o,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${o}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${o}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${o}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${o}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${o}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${o}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(La,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(La,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${o}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${o}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const L3=typeof n1>"u"?{commit:"unknown"}:n1,q3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=L3,o=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),o]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},B3=(t,e,n)=>t==="dark"?n:e,$3="Runtime intelligence returned an invalid snapshot.",I3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),H3=new Set(["error","warning","info"]),z3=new Set(["pass","warn","fail","partial"]);function sn(){throw new Error($3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&sn(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&sn(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];sn()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&sn(),n}function U3(t){return Ji(t)||sn(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||sn(),t.map(U3)}function V3(t){(!Ji(t)||!Ji(t.location))&&sn();const e=Un(t,"code"),n=Un(t,"severity");(!I3.has(e)||!H3.has(n)||t.location.kind!=="operation")&&sn();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const o=i1(t,"expected");o!==void 0&&(r.expected=o);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),t.disposition!==void 0&&(t.disposition!=="acknowledged"&&sn(),r.disposition="acknowledged"),r}function F3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&sn();const e=Un(t,"status");z3.has(e)||sn();const n=t.findings.map(V3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&sn();const o=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==o&&sn(),{status:e,complete:t.complete,findings:n,summary:r}}function P3(t){Ji(t)||sn(),(!Ji(t.runtime)||!Ji(t.summary))&&sn(),typeof t.discoveryComplete!="boolean"&&sn();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const o=Zh(t,"serverOrigin");if(o&&(r.serverOrigin=o),t.server!==void 0){Ji(t.server)||sn();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&sn(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||sn(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=F3(t.validation)),r}const Y3=60;function K3(t,e,n=Y3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function G3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const X3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:o,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:o},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,o,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=K3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=G3(C.current);if(!J.length)return;const ae=J[0],he=J[J.length-1],we=document.activeElement;q.shiftKey&&(we===ae||!C.current.contains(we))?(q.preventDefault(),he.focus()):!q.shiftKey&&(we===he||!C.current.contains(we))&&(q.preventDefault(),ae.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},J3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function Q3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:o,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=W3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(o)?o.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:Q3(o),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(o)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),J3[D]]},D))]}),o!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function eM(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const tM=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:o,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),o();return}if(j.key!=="Tab"||!f.current)return;const R=eM(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,o]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:o}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:o,children:p.jsx(Md,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(nM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),o())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function nM({result:t,theme:e,messages:n,onSelect:r}){const o=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:o,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code}),u.disposition==="acknowledged"&&p.jsx("span",{children:n?.acknowledgedFinding||"acknowledged"})]}),p.jsx("div",{className:`mt-1 text-xs ${o}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${o}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${o}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:o,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>o?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>o(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function iM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Zc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function eu(t){return Array.isArray(t)?`[${t.map(eu).join(",")}]`:Zc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${eu(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function rM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function o1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){o1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function sM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function a1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let o=n?s.get(n):void 0;for(;o&&!r.has(o.id);)r.add(o.id),o=o.parentFolderId?s.get(o.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const o of t.folders)o.collectionId!==e||!o.parentFolderId||r.has(o.id)||r.has(o.parentFolderId)&&(r.add(o.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const o=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))o.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&o.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function lM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[sM(r)],activeEnvironmentId:r.id}}function oM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=a1(r,e),o=f1(r,e);h1(o,e);const c=lM(r,n.environmentId),u={version:6,collections:[rM(s)],folders:d1(r,e),requests:o,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function aM(t){if(!Zc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function tu(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function cM(t,e){const n=a1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(o=>o.id===e.folderId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(o=>o.id===e.requestId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function uM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function dM(t){if(!Zc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Zc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=aM(t.scope),n=uM(t.workspace),r=oy(n);if(eu(n)!==eu(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");tu(r.collections,"collection"),tu(r.folders,"folder"),tu(r.requests,"request"),tu(r.environments,"environment"),cM(r,e);for(const s of r.requests)o1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function fM(t){return`${JSON.stringify(dM(t),null,2)} +`}function hM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let o=!0;for(;o;){o=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),o=!0)}return s}function Sl(t,e,n){const r=hM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function pM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(o=>o.id===e)?.name||"Deleted collection";if(!n)return r;const s=pM(t.folders.filter(o=>o.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function mM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function gM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const o=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=pf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&mM(E);let j;E.result&&!D&&(s=ay(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(o.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=o.filter(g=>g.cancelled).length,h=o.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:o.length,passed:u,failed:h,cancelled:f,stopped:c,items:o,workspace:s}}function Gr(){return new Date().toISOString()}function yM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const bM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:o,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,Se=(Ne,Be)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:Be}),Se(We.id,Be+1))})};return Se(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),Se(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],Se=new Set;let Ne=K.get(Q);for(;Ne&&!Se.has(Ne.id);)Se.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const Se=oM(h,Q),Ne=new Blob([fM(Se)],{type:"application/json;charset=utf-8"}),Be=URL.createObjectURL(Ne),We=document.createElement("a");We.href=Be,We.download=yM(re),We.click(),setTimeout(()=>URL.revokeObjectURL(Be),0),L("")}catch(Se){L(Se instanceof Error?Se.message:String(Se))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),Se=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:Se,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(Se),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(Se=>({...Se,folders:Se.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},ae=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(Se=>Se.id===M.id?{...Se,variables:[...Se.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:Se)}))},he=(Q,re)=>{if(!M)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Be=>Be.id===M.id?{...Be,variables:Be.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:Se}:Be)}))},we=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter(Be=>Be.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),Se=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:Se,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(Se),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map(Be=>Be.id===j?{...Be,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:Be)}));return}const Se={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,Se]})),R(Se.id),O(Q)},me=Q=>{const re=h.requests.find(Se=>Se.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(Se=>Se.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(Se=>Se.id===Q);g(Se=>LC(Se,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",$e=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),ft=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=be(Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return p.jsxs(kd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Be}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${Be} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},Be),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(lt=>ft(lt,re+1,Ne))]},Q.id)},At=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=Y.filter(lt=>lt.folderId===Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return Be.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Be.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:Be.map($e)})]}),We.map(lt=>At(lt,re+1,Ne))]},Q.id)},bt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>o?.(Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(xf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:ae,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:Se=>he(Q.id,{enabled:Se.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:Se=>he(Q.id,{key:Se.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:Se=>he(Q.id,{value:Se.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>we(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),bt.map(Q=>ft(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(xf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map($e),bt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function Uo(){return new Date().toISOString()}const xM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),o=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=Uo(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!o)return;const w=Uo();e(A=>({...A,environments:A.environments.map(C=>C.id===o.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!o)return;const C=Uo();e(E=>({...E,environments:E.environments.map(D=>D.id===o.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),o&&p.jsx("button",{type:"button","aria-label":`Delete environment ${o.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,o.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),o&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:o.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[o.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),o.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function nu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function vM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",o=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,o,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=nu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function wM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),o=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:o,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const o=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=kd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` -`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${o}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:o,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${o}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":o,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":o}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${o}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${o}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function op(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function AM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=AM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,o)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${o}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const kM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:o,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:o||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>vM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>wM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},ae=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],we=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:ae,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=nu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[op(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:nu(ne)?"text-red-600":j,children:op(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:nu(B)?"text-red-600":j,children:op(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[we,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ot(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?ot(r.value):""}function CM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function ap(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=CM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const o=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return o("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){o("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return o("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){o("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(o("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const o=ot(r.key).trim();return o?[{id:An("variable"),key:o,value:ot(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function NM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(o=>t.includes(o));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function TM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(ot).join(` +`):ot(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,o)=>{const c=ot(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${o}]`,f=TM(s.script,`${u}.script`,n).trim();if(!f)return;const h=NM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function jM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function EM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(o=>{const c=o.indexOf("=");return{key:S1(c>=0?o.slice(0,c):o),value:S1(c>=0?o.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function OM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function MM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=ot(r.key).trim();s&&(n=n.replace(new RegExp(`:${MM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function RM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=OM(t.query),n=ot(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=ot(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(ot).join("."):ot(t.host),o=ot(t.port),c=Array.isArray(t.path)?t.path.map(ot).join("/"):ot(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${o?`:${o}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function DM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function _M(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function LM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function qM(t,e,n,r){const s=_M(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const o=ot(t.mode);if(o==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?ot(c.language):"";return{body:ot(t.raw),contentType:s||LM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(o==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:ot(u.key),value:ot(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(o==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=ot(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:ot(c.query),variables:u},contentType:s||"application/json"}}if(o==="formdata"){const c=Xr(t.formdata).map(f=>{const h=ot(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(ot).filter(Boolean).join(", "):ot(f.src);return{key:ot(f.key),value:h==="text"?ot(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(o==="file"){const c=mn(t.file)?ot(t.file.src):ot(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${o}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function BM(t,e,n,r,s,o,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=ot(f.method).trim().toUpperCase()||"GET",g=RM(f.url),b=DM(f.header),v=qM(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:ap(f.auth,{type:"inherit"},`${c}.auth`,u)},A=EM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:o,updatedAt:o}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=ot(e.name)||"Untitled",o=w1(e.event,`${r}.event`,t.warnings),c=jM(t.inheritedScripts,o);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:ap(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=BM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function $M(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=ot(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=ot(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),o=An("collection"),c={id:o,name:e,auth:ap(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:o,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function IM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=ot(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function HM(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:$M(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:IM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function zM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function UM(t,e){const n=zM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function VM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const FM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,o]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=HM(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?UM(M,G.result):VM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?o({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?o({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):o({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(ao,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function PM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e.folderId);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function YM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const KM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const ae=await gM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(we=>({...we,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(we=>({...we,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(ae.workspace),Y(he=>Object.fromEntries(C.map(we=>{const T=he[we.id]||{status:"pending"};return[we.id,T.status==="pending"&&ae.stopped?{status:"skipped"}:T]}))),M(ae),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(co,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(co,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,ae)=>{const he=G[J.id]||{status:"pending"},we=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=we?.status!==void 0&&we.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:ae+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:PM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(ao,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:YM(he)}),we?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",we.status]}),we?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(Nd,{className:"mr-1 inline h-3.5 w-3.5"}),we.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Vo(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function GM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return po(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function XM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:o="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=GM(t),Y=Sn(e),B=nl(),K=o===!1?{}:j1(o),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[ae,he]=I.useState(Y),[we,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[$e,ft]=I.useState({}),[At,bt]=I.useState(),[Ge,Q]=I.useState(B),[re,Se]=I.useState(B.collections[0]?.id),[Ne,Be]=I.useState(""),We=I.useRef(B.collections[0]?.id),lt=I.useRef(void 0),[ti,Tn]=I.useState(o===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(o===!1)return;let Me=!1;return hy(o).then(Ze=>{Me||(Q(Ze),Se(Ze.collections[0]?.id),Be(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[o]);const x=my(o,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>hf(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,ae),[ce,ae]),V=I.useMemo(()=>XM(ce,ae)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,ae,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),ve=I.useCallback(Me=>{Se(Me),Be("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},le=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),o!==!1&&Vo(o,{requestTab:Me}),C?.(Me)},Te=Me=>{qe(Me),o!==!1&&Vo(o,{scriptTab:Me}),E?.(Me)},je=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>pf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,lt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>ay(Ze,{...Me,collectionId:We.current,folderId:lt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Se(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Be(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),o!==!1&&Vo(o,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{Se(Me),Be(Ze||""),bt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{ft({entryId:Me,runId:Ze}),Je("history")},Fo=()=>ni(Me=>{const Ze=!Me;return o!==!1&&Vo(o,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Fo,children:ht?p.jsx(Ed,{className:"h-4 w-4"}):p.jsx(jd,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(bf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(FM,{onWorkspaceChange:Q,onSelectedCollectionChange:ve,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(xM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(bM,{request:ce,scripts:ae,onLoadRequest:Dt,onSelectedCollectionChange:ve,onSelectedFolderChange:Be,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),o!==!1&&Vo(o,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(kM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:$e.entryId,initialRunId:$e.runId,theme:kt},`${$e.runId||""}:${$e.entryId||""}`):He==="runner"&&At?p.jsx(KM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:we,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:je,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:le,onRequestTabChange:Ae,onScriptTabChange:Te,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function iu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function JM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,o]of Object.entries(t.paths))for(const c of In.getHttpMethods(o)){if(Wc(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function QM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${iu(n.padding.vertical)||"0"} ${iu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:iu(n.maxHeight)||"32px",maxWidth:iu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const WM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const o=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=ho(o),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:o,preferences:c})),ae=I.useRef(null),he=I.useRef(null),we=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===o?q.preferences:ho(o),Je=n&&He.theme||e,$e=Je==="high-contrast"?"dark":Je,ft=He.expand,At=He.expandedTags??["default"],bt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...JM($e,Ge),...r}),[$e,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return P3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const le=R1(t,window.location.hash);if(le){g(le);return}const Ae=window.location.hash.replace(/^#/,"");g(Te=>Te&&Ae&&Wc(Te.path,Te.method)===Ae?Te:null)},de=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const le=ae.current,Ae=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Te=je=>{if(je.key==="Escape"){je.preventDefault(),M(!1);return}if(je.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];je.shiftKey&&document.activeElement===ze?(je.preventDefault(),Ve.focus()):!je.shiftKey&&document.activeElement===Ve&&(je.preventDefault(),ze.focus())};return document.addEventListener("keydown",Te),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Te),de?.focus()}},[L]);const re=()=>{J({key:o,preferences:ho(o)})},Se=F=>{J(de=>{const le=de.key===o?de.preferences:ho(o);return{key:o,preferences:{...le,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>we.current?.scrollTo({top:0,behavior:"auto"})),Be=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wc(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},lt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!bt;Ba(o,"sidebarCollapsed",F),Se({sidebarCollapsed:F})},ht=nf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ft===void 0?ht:nf(ft),Vn=F=>{Ba(o,"expand",F),re()},qn=F=>{n&&(Ba(o,"theme",F),re())},kt=F=>{Ba(o,"expandedTags",F),Se({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=B3($e,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=$e==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=$e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),ve=p.jsx(pk,{spec:t,onEndpointSelect:Be,theme:$e,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.logo?p.jsx(QM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(iM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${bt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":bt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!bt&&ve}),p.jsxs("main",{ref:we,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(O3,{spec:t,path:h.path,method:h.method,theme:$e,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:lt}):p.jsx(_3,{spec:t,onEndpointSelect:Be,theme:$e}),p.jsx(q3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:$e,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:ae,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${$e==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:ve})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${$e==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(tM,{open:B&&T,theme:$e,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:Be,messages:X}),p.jsx(X3,{spec:t,theme:$e,messages:X,onEndpointSelect:Be,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>lt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Z3,{open:G,theme:$e,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:ft,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function ZM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function eR(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function tR(t,e){const n=e.load||ZM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),o={},c=new Map;async function u(g){if(g===r)return s;if(o[g])return o[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return o[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=eR(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(o).length&&(s[dp]=o),s}async function nR(t,e){return tR(t,e)}const ru="1",su=new WeakMap;function iR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=iR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},o=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!o.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function rR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function sR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=su.get(t);n&&n.unmount();const r=$A.createRoot(t);return su.set(t,r),r.render(e),()=>{su.get(t)===r&&su.delete(t),r.unmount()}}function $1(t,e,n){return sR(n),B1(t,p.jsx(WM,{spec:fp(e,n),theme:rR(n),options:n}))}function I1(t,e){const n={contractVersion:ru,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:ru,...e.options||{}},r=e.baseUri?await nR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:ru}),As.FLEXDOC_CONTRACT_VERSION=ru,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/rust/assets/flexdoc.standalone.js b/adapters/rust/assets/flexdoc.standalone.js index 3efc5433..bf78a4d9 100644 --- a/adapters/rust/assets/flexdoc.standalone.js +++ b/adapters/rust/assets/flexdoc.standalone.js @@ -1,86 +1,86 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(q,J){var oe=q.length;q.push(J);e:for(;0>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1>>1,we=q[he];if(0>>1;hes(me,ae))nes(Ce,me)?(q[he]=Ce,q[ne]=ae,he=ne):(q[he]=me,q[z]=ae,he=z);else if(nes(Ce,ae))q[he]=Ce,q[ne]=ae,he=ne;else break e}}return J}function s(q,J){var ae=q.sortIndex-J.sortIndex;return ae!==0?ae:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var we=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof we=="function"){b.callback=we,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=ae,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=ae,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,ae-he))):(q.sortIndex=we,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var ae=v;v=J;try{return q.apply(this,arguments)}finally{v=ae}}}})(vd)),vd}var Ng;function RA(){return Ng||(Ng=1,xd.exports=MA()),xd.exports}var wd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function($e){return $e})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ad.exports=_A(),Ad.exports}var Mg;function qA(){if(Mg)return oo;Mg=1;var t=RA(),e=Sd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1we||(i.current=he[we],he[we]=null,we--)}function me(i,l){we++,he[we]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function $e(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,a=Q2(l,i.type);l!==a&&(me(Ce,i),me(ne,a))}function ft(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oa._currentValue=ae)}var At,bt;function Ge(i){if(At===void 0)try{throw Error()}catch(a){var l=a.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",bt=-1)":-1m||$[d]!==te[m]){var fe=` -`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Ge(a):""}function Se(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",a=null;do l+=Se(i,a),a=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var $e=Object.prototype.hasOwnProperty,We=t.unstable_scheduleCallback,vt=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ft=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,kt=t.unstable_NormalPriority,x=t.unstable_LowPriority,U=t.unstable_IdlePriority,pe=t.log,ue=t.unstable_setDisableYieldValue,X=null,k=null;function V(i){if(typeof pe=="function"&&ue(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var W=Math.clz32?Math.clz32:de,we=Math.log,F=Math.LN2;function de(i){return i>>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(ve(i)/F|0)|0}var le=256,Ae=262144,Te=4194304;function je(i){var l=i&42;if(l!==0)return l;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,a){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=je(d):(S&=N,S!==0?m=je(S):a||(a=N&~i,a!==0&&(m=je(a))))):(N=d&~y,N!==0?m=je(N):S!==0?m=je(S):a||(a=d&~i,a!==0&&(m=je(a)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,a=l&-l,y>=a||y===32&&(a&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Dt(){var i=Te;return Te<<=1,(Te&62914560)===0&&(Te=4194304),i}function Fn(i){for(var l=[],a=0;31>a;a++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Fo(i,l,a,d,m,y){var S=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(a=S&~a;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var oR=/[\n"\\]/g;function vi(i){return i.replace(oR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,a,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):a!=null?gp(i,S,On(a)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,a,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||a!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}a=a!=null?""+On(a):"",l=l!=null?""+On(l):a,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,a){l==="number"&&ou(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Tl(i,l,a,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Go={};Object.defineProperty(Go,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Go,Go),window.removeEventListener("test",Go,Go)}catch{wp=!1}var es=null,Sp=null,cu=null;function Q1(){if(cu)return cu;var i,l=Sp,a=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Qo),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return LR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function BR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function $R(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),cu=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:a,offset:l-i};i=d}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=pw(a)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=ou(i.document);l instanceof i.HTMLIFrameElement;){try{var a=typeof l.contentWindow.location.href=="string"}catch{a=!1}if(a)i=l.contentWindow;else break;l=ou(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var YR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,ta=null,Rp=!1;function bw(i,l,a){var d=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Rp||Rl==null||Rl!==ou(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),ta&&ea(ta,d)||(ta=d,d=nd(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|a<it?(dt=Ie,Ie=null):dt=Ie.sibling;var vt=ie(P,Ie,Z[it],ye);if(vt===null){Ie===null&&(Ie=dt);break}i&&Ie&&vt.alternate===null&&l(P,Ie),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt,Ie=dt}if(it===Z.length)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;itit?(dt=Ie,Ie=null):dt=Ie.sibling;var Ss=ie(P,Ie,vt.value,ye);if(Ss===null){Ie===null&&(Ie=dt);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),xt===null?Fe=Ss:xt.sibling=Ss,xt=Ss,Ie=dt}if(vt.done)return a(P,Ie),pt&&gr(P,it),Fe;if(Ie===null){for(;!vt.done;it++,vt=Z.next())vt=xe(P,vt.value,ye),vt!==null&&(H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return pt&&gr(P,it),Fe}for(Ie=d(Ie);!vt.done;it++,vt=Z.next())vt=oe(Ie,P,it,vt.value,ye),vt!==null&&(i&&vt.alternate!==null&&Ie.delete(vt.key===null?it:vt.key),H=y(vt,H,it),xt===null?Fe=vt:xt.sibling=vt,xt=vt);return i&&Ie.forEach(function(fD){return l(P,fD)}),pt&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){a(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){a(P,H.sibling),ye=m(H,Z.props),oa(ye,Z),ye.return=P,P=ye;break e}a(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=xu(Z.type,Z.key,Z.props,null,P.mode,ye),oa(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){a(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{a(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,Nu(Z),ye);if(Z.$$typeof===j)return Et(P,H,Su(P,Z),ye);Tu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(a(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(a(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):a(P,H)}return function(P,H,Z,ye){try{la=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===ku)throw Ie;var xt=li(29,Ie,null,P.mode);return xt.lanes=ye,xt.return=P,xt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function os(i,l,a){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=bu(i),Cw(i,null,a),l}return yu(i,d,l,a),bu(i)}function aa(i,l,a){if(l=l.updateQueue,l!==null&&(l=l.shared,(a&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}function Zp(i,l){var a=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,a===d)){var m=null,y=null;if(a=a.firstBaseUpdate,a!==null){do{var S={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,a=a.next}while(a!==null);y===null?m=y=l:y=y.next=l}else m=y=l;a={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=l:i.next=l,a.lastBaseUpdate=l}var em=!1;function ca(){if(em){var i=zl;if(i!==null)throw i}}function ua(i,l,a,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,oe=ie!==N.lane;if(oe?(ut&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=a;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=m.callbacks,oe===null?m.callbacks=[ie]:oe.push(ie))}else oe={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=oe,$=xe):fe=fe.next=oe,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;oe=N,N=oe.next,oe.next=null,m.lastBaseUpdate=oe,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,a);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=t4($,d);ha(i,l,fe,di(i))}else ha(i,l,d,di(i))}catch(xe){ha(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function o4(){}function ym(i,l,a,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,ae,a===null?o4:function(){return AS(i),a(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:ae},next:null};var a={};return l.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ha(i,l.next.queue,{},di())}function bm(){return yn(Oa)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function a4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var a=di();i=ls(a);var d=os(l,i,a);d!==null&&(Qn(d,l,a),aa(d,l,a)),l={cache:Kp()},i.payload=l;return}l=l.return}}function c4(i,l,a){var d=di();a={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bu(i)?TS(l,a):(a=qp(i,l,a,d),a!==null&&(Qn(a,i,d),jS(a,l,d)))}function NS(i,l,a){var d=di();ha(i,l,a,d)}function ha(i,l,a,d){var m={lane:d,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,a);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return yu(i,l,m,0),Mt===null&&gu(),!1}catch{}if(a=qp(i,l,m,d),a!==null)return Qn(a,i,d),jS(a,l,d),!0}return!1}function xm(i,l,a,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Bu(i)){if(l)throw Error(r(479))}else l=qp(i,a,d,2),l!==null&&Qn(l,i,2)}function Bu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=Ou=!0;var a=i.pending;a===null?l.next=l:(l.next=a.next,a.next=l),i.pending=l}function jS(i,l,a){if((a&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,a|=d,l.lanes=a,Bs(i,a)}}var pa={readContext:yn,use:Du,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};pa.useEffectEvent=zt;var ES={readContext:yn,use:Du,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,a){a=a!=null?a.concat([i]):null,Lu(4194308,4,gS.bind(null,l,i),a)},useLayoutEffect:function(i,l){return Lu(4194308,4,i,l)},useInsertionEffect:function(i,l){Lu(4,2,i,l)},useMemo:function(i,l){var a=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return a.memoizedState=[d,l],d},useReducer:function(i,l,a){var d=$n();if(a!==void 0){var m=a(l);if(Js){V(!0);try{a(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=c4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,a=NS.bind(null,nt,l);return l.dispatch=a,[i.memoizedState,a]},useDebugValue:mm,useDeferredValue:function(i,l){var a=$n();return gm(a,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,a){var d=nt,m=$n();if(pt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=l(),Mt===null)throw Error(r(349));(ut&127)!==0||Jw(d,l,a)}m.memoizedState=a;var y={value:a,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,a,l),null),a},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(pt){var a=Zi,d=Wi;a=(d&~(1<<32-W(d)-1)).toString(32)+a,l="_"+l+"R_"+a,a=Mu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,a),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,a=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===a||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,a)),i||is(l,!0)}else i=id(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(a=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),a!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else a=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return l.flags&256?(ai(l),l):(ai(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(ai(l),l):(ai(l),null)}return ai(l),(l.flags&128)!==0?(l.lanes=a,l):(a=d!==null,i=i!==null&&i.memoizedState!==null,a&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),a!==i&&a&&(l.child.flags|=8192),Uu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)ga(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Eu(i),y!==null){for(l.flags|=128,ga(d,!1),i=y.updateQueue,l.updateQueue=i,Uu(l,i),l.subtreeFlags=0,i=a,a=l.child;a!==null;)Nw(a,i),a=a.sibling;return me(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Ku&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304)}else{if(!m)if(i=Eu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Uu(l,i),ga(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Ku&&a!==536870912&&(l.flags|=128,m=!0,ga(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,a=Kt.current,me(Kt,m?a&1|2:a&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return ai(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(a&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),a=l.updateQueue,a!==null&&Uu(l,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==a&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),l.memoizedState.cache!==a&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function p4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ft(l),null;case 31:if(l.memoizedState!==null){if(ai(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(ai(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return ai(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:ft(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&ai(l);break;case 13:ai(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:ai(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function ya(i,l){try{var a=l.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var m=d.next;a=m;do{if((a.tag&i)===i){d=void 0;var y=a.create,S=a.inst;d=y(),S.destroy=d}a=a.next}while(a!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,a){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=a,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var a=i.stateNode;try{Fw(l,a)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,a){a.props=Qs(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(d){Nt(i,l,d)}}function ba(i,l){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof a=="function"?i.refCleanup=a(d):a.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var a=i.ref,d=i.refCleanup;if(a!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(m){Nt(i,l,m)}else a.current=null}function n2(i){var l=i.type,a=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":a.autoFocus&&d.focus();break e;case"img":a.src?d.src=a.src:a.srcSet&&(d.srcset=a.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,a){try{var d=i.stateNode;q4(d,i.type,a,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,l):(l=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,l.appendChild(i),a=a._reactRootContainer,a!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,a),i=i.sibling;i!==null;)qm(i,l,a),i=i.sibling}function Vu(i,l,a){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?a.insertBefore(i,l):a.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vu(i,l,a),i=i.sibling;i!==null;)Vu(i,l,a),i=i.sibling}function r2(i){var l=i.stateNode,a=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,a),l[_t]=i,l[Yt]=a}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,an=null;function m4(i,l){if(i=i.containerInfo,rg=ud,i=yw(i),Op(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var d=a.getSelection&&a.getSelection();if(d&&d.rangeCount!==0){a=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{a.nodeType,y.nodeType}catch{a=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var oe;xe!==a||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(oe=xe.firstChild)!==null;)ie=xe,xe=oe;for(;;){if(xe===i)break t;if(ie===a&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(oe=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=oe}a=N===-1||$===-1?null:{start:N,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(sg={focusedElem:i,selectionRange:a},ud=!1,an=l;an!==null;)if(l=an,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,an=i;else for(;an!==null;){switch(l=an,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a title"))),xn(y,d,a),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(a.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(oe.rangeCount!==1||oe.anchorNode!==P.node||oe.anchorOffset!==P.offset||oe.focusNode!==H.node||oe.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),oe.removeAllRanges(),Ye>Et?(oe.addRange(Z),oe.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),oe.addRange(Z))}}}}for(xe=[],oe=N;oe=oe.parentNode;)oe.nodeType===1&&xe.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Na?32:a,q.T=null,a=Fm,Fm=null;var y=ps,S=jr;if(ln=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,a),wt=N,ka(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,a){l=Si(a,l),l=Am(i.stateNode,l,2),i=os(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,a){if(i.tag===3)q2(i,i,a);else for(;l!==null;){if(l.tag===3){q2(l,i,a);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(a,i),a=BS(2),d=os(l,a,2),d!==null&&($S(a,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,a){var d=i.pingCache;if(d===null){d=i.pingCache=new b4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(a)||(Hm=!0,m.add(a),i=A4.bind(null,i,l,a),l.then(i,i))}function A4(i,l,a){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ut&a)===a&&(Ut===4||Ut===3&&(ut&62914560)===ut&&300>ht()-Yu?(wt&2)===0&&Zl(i,0):zm|=a,Ql===ut&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function k4(i){var l=i.memoizedState,a=0;l!==null&&(a=l.retryLane),B2(i,a)}function C4(i,l){var a=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(a=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,a)}function N4(i,l){return We(i,l)}var Zu=null,to=null,Xm=!1,ed=!1,Jm=!1,gs=0;function tr(i){i!==to&&i.next===null&&(to===null?Zu=to=i:to=to.next=i),ed=!0,Xm||(Xm=!0,j4())}function ka(i,l){if(!Jm&&ed){Jm=!0;do for(var a=!1,d=Zu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(a=!0,z2(d,y))}else y=ut,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(a=!0,z2(d,y));d=d.next}while(a);Jm=!1}}function T4(){$2()}function $2(){ed=Xm=!1;var i=0;gs!==0&&$4()&&(i=gs);for(var l=ht(),a=null,d=Zu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,a===null?Zu=m:a.next=m,m===null&&(to=a)):(a=d,(i!==0||(y&3)!==0)&&(ed=!0)),d=m}ln!==0&&ln!==5||ka(i),gs!==0&&(gs=0)}function I2(i,l){for(var a=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function oA(i,l,a){var d=no;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof a=="string"&&(m+='[crossorigin="'+a+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:a,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function K4(i){Er.D(i),oA("dns-prefetch",i,null)}function G4(i,l){Er.C(i,l),oA("preconnect",i,l)}function X4(i,l,a){Er.L(i,l,a);var d=no;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&a&&a.imageSrcSet?(m+='[imagesrcset="'+vi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(m+='[imagesizes="'+vi(a.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=io(i);break;case"script":y=ro(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&a&&a.imageSrcSet?void 0:i,as:l},a),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(ja(y))||l==="script"&&d.querySelector(Ea(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function J4(i,l){Er.m(i,l);var a=no;if(a&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ro(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),a.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ea(y)))return}d=a.createElement("link"),xn(d,"link",i),Xt(d),a.head.appendChild(d)}}}function Q4(i,l,a){Er.S(i,l,a);var d=no;if(d&&i){var m=fr(d).hoistableStyles,y=io(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(ja(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},a),(a=ji.get(y))&&fg(i,a);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,sd(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function W4(i,l){Er.X(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Z4(i,l){Er.M(i,l);var a=no;if(a&&i){var d=fr(a).hoistableScripts,m=ro(i),y=d.get(m);y||(y=a.querySelector(Ea(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=a.createElement("script"),Xt(y),xn(y,"link",i),a.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function aA(i,l,a,d){var m=(m=Re.current)?rd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(l=io(a.href),a=fr(m).hoistableStyles,d=a.get(l),d||(d={type:"style",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=io(a.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(ja(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ji.set(i,a),y||eD(m,i,a,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=a.async,a=a.src,typeof a=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ro(a),a=fr(m).hoistableScripts,d=a.get(l),d||(d={type:"script",instance:null,count:0,state:null},a.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function io(i){return'href="'+vi(i)+'"'}function ja(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function eD(i,l,a,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",a),Xt(l),i.head.appendChild(l))}function ro(i){return'[src="'+vi(i)+'"]'}function Ea(i){return"script[async]"+i}function uA(i,l,a){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(a.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),sd(d,a.precedence,i),l.instance=d;case"stylesheet":m=io(a.href);var y=i.querySelector(ja(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(a),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,sd(y,a.precedence,i),l.instance=y;case"script":return y=ro(a.src),(m=i.querySelector(Ea(y)))?(l.instance=m,Xt(m),m):(d=a,(m=ji.get(y))&&(d=b({},a),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,sd(d,a.precedence,i));return l.instance}function sd(i,l,a){for(var d=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function tD(i,l,a){if(a===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function nD(i,l,a,d){if(a.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var m=io(d.href),y=l.querySelector(ja(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=od.bind(i),l.then(i,i)),a.state.loading|=4,a.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),a.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,l),(l=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=od.bind(i),l.addEventListener("load",a),l.addEventListener("error",a))}}var pg=0;function iD(i,l){return i.stylesheets&&i.count===0&&cd(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function od(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ad=null;function cd(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ad=new Map,l.forEach(rD,i),ad=null,od.call(i))}function rD(i,l){if(!(l.state.loading&4)){var a=ad.get(i);if(a)var d=a.get(null);else{a=new Map,ad.set(i,a);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),bd.exports=qA(),bd.exports}var $A=BA(),I=Sd();const kd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!o&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(o)?o:[o]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},o)=>I.createElement(VA,{ref:o,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _a=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Cd=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const ao=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Nd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("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"}]]);const Td=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const La=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const jd=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const Ed=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const co=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Od=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Md=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},qa={},Or={},Pg;function uo(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` -`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` -`,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` -`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentb&&(h=" ... ",o=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(o,c).replace(/\t/g,"→")+g,pos:u-o+h.length}}function n(s,o){return t.repeat(" ",o-s.length)+s}function r(s,o){if(o=Object.create(o||null),!s.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+o.linesAfter,f.length).toString().length,w=o.maxLength-(o.indent+v+3);for(let C=1;C<=o.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",o.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` +`+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",o.indent)+n((s.line+1).toString(),v)+" | "+A.str+` +`,b+=t.repeat("-",o.indent+v+3+A.pos)+`^ +`;for(let C=1;C<=o.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",o.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Dd=r,Dd}var _d,Gg;function Mn(){if(Gg)return _d;Gg=1;const t=fo(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(o){const c={};return o!==null&&Object.keys(o).forEach(function(u){o[u].forEach(function(f){c[String(f)]=u})}),c}function s(o,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+o+'" YAML type.')}),this.options=c,this.tag=o,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return _d=s,_d}var Ld,Xg;function Jg(){if(Xg)return Ld;Xg=1;const t=fo(),e=Mn();function n(o,c){const u=[];return o[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(o.multi[u.kind].push(u),o.multi.fallback.push(u)):o[u.kind][u.tag]=o.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function o(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ud}var Vd,d0;function f0(){if(d0)return Vd;d0=1;const t=uo(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function o(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Vd=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:o,predicate:f,represent:u,defaultStyle:"lowercase"}),Vd}var Fd,h0;function p0(){return h0||(h0=1,Fd=r0().extend({implicit:[l0(),a0(),u0(),f0()]})),Fd}var Pd,m0;function g0(){return m0||(m0=1,Pd=p0()),Pd}var Yd,y0;function b0(){if(y0)return Yd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function o(c){return c.toISOString()}return Yd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:o}),Yd}var Kd,x0;function v0(){if(x0)return Kd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Kd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Kd}var Gd,w0;function S0(){if(w0)return Gd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function o(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Gd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:o,represent:s}),Gd}var Xd,A0;function k0(){if(A0)return Xd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(o){if(o===null)return!0;const c={},u=o;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function ae(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function we(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function bt(x,U,pe){let ue,X,k,V,W,ve;const F=x.kind,de=x.result;let le=x.input.charCodeAt(x.position);if(R(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;le!==0;){if(le===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(le===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&ft(x)||pe&&_(le))break;if(O(le))if(V=x.line,W=x.lineStart,ve=x.lineIndent,$e(x,!1,-1),x.lineIndent>=U){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=ve;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))$e(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,$e(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&ft(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const ve=x.anchor;let F,de,le,Ae;const Te=Object.create(null);let je,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&ae(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if($e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=ve,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=je=ze=null,de=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=le=!0,x.position++,$e(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ht(x,U,o,!1,!0),Le=x.tag,je=x.result,$e(x,!0,U),Ve=x.input.charCodeAt(x.position),(le||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),$e(x,!0,U),ht(x,U,o,!1,!0),ze=x.result),Ae?He(x,W,Te,Le,je,ze,ue,X,k):de?W.push(He(x,null,Te,Le,je,ze,ue,X,k)):W.push(je),$e(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function Se(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,ve=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` -`,de=we&&(k[k.length-2]===` +`,X?1+W:W),X=!0,k=!0,W=0;const le=x.position;for(;!O(de)&&de!==0;)de=x.input.charCodeAt(++x.position);Ce(x,le,x.position,!1)}return!0}function Ne(x,U){const pe=x.tag,ue=x.anchor,X=[];let k=!1;if(x.firstTabInLine!==-1)return!1;x.anchor!==null&&ae(x,x.anchor,X);let V=x.input.charCodeAt(x.position);for(;V!==0&&(x.firstTabInLine!==-1&&(x.position=x.firstTabInLine,q(x,"tab characters must not be used in indentation")),V===45);){const W=x.input.charCodeAt(x.position+1);if(!R(W))break;if(k=!0,x.position++,$e(x,!0,-1)&&x.lineIndent<=U){X.push(null),V=x.input.charCodeAt(x.position);continue}const ve=x.line;if(ht(x,U,u,!1,!0),X.push(x.result),$e(x,!0,-1),V=x.input.charCodeAt(x.position),(x.line===ve||x.lineIndent>U)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(je&&(X=x.line,k=x.lineStart,V=x.position),ht(x,U,f,!0,ue)&&(je?Ae=x.result:Te=x.result),je||(He(x,F,de,le,Ae,Te,X,k,V),le=Ae=Te=null),$e(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const je=k=V=f===pe||u===pe;if(ue&&$e(x,!0,-1)&&(ve=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&le.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&ae(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&($e(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if($e(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,$e(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),$e(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ft(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,$e(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==o||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==o&&k!==f&&k!==u}function He(k,V,W){const ve=qe(k),F=ve&&!Ce(k);return(W?ve:ve&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==o&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function $e(k){return!Ce(k)&&k!==j}function ft(k,V){const W=k.charCodeAt(V);let ve;return W>=55296&&W<=56319&&V+1=56320&&ve<=57343)?(W-55296)*1024+ve-56320+65536:W}function At(k){return/^\n* /.test(k)}const bt=1,Ge=2,Q=3,re=4,Se=5;function Ne(k,V,W,ve,F,de,le,Ae){let Te,je=0,Le=null,ze=!1,Ve=!1;const Dt=ve!==-1;let Fn=-1,jn=Je(ft(k,0))&&$e(ft(k,k.length-1));if(V||le)for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}else{for(Te=0;Te=65536?Te+=2:Te++){if(je=ft(k,Te),je===u)ze=!0,Dt&&(Ve=Ve||Te-Fn-1>ve&&k[Fn+1]!==" ",Fn=Te);else if(!Re(je))return Se;jn=jn&&He(je,Le,Ae),Le=je}Ve=Ve||Dt&&Te-Fn-1>ve&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!F(k)?bt:de===we?Se:Ge:W>9&&At(k)?Se:le?de===we?Se:Ge:Ve?re:Q}function Be(k,V,W,ve,F){k.dump=(function(){if(V.length===0)return k.quotingType===we?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===we?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=ve||k.flowLevel>-1&&W>=k.flowLevel;function Te(je){return ne(k,je)}switch(Ne(V,Ae,k.indent,le,Te,k.quotingType,k.forceQuotes&&!ve,F)){case bt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+lt(z(V,de));case re:return">"+We(V,k.indent)+lt(z(ti(V,le),de));case Se:return'"'+ht(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",ve=k[k.length-1]===` +`,de=ve&&(k[k.length-2]===` `||k===` -`)?"+":we?"":"-";return W+de+` -`}function vt(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`)?"+":ve?"":"-";return W+de+` +`}function lt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let ve=(function(){let Ae=k.indexOf(` `);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` -`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` -`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` -`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` -`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` -`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ -`)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); -const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` -`)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` -`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`||k[0]===" ",de,le;for(;le=W.exec(k);){const Ae=le[1],Te=le[2];de=Te[0]===" ",ve+=Ae+(!F&&!de&&Te!==""?` +`:"")+Tn(Te,V),F=de}return ve}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let ve,F=0,de,le=0,Ae=0,Te="";for(;ve=W.exec(k);)Ae=ve.index,Ae-F>V&&(de=le>F?le:Ae,Te+=` +`+k.slice(F,de),F=de+1),le=Ae;return Te+=` +`,k.length-F>V&&le>F?Te+=k.slice(F,le)+` +`+k.slice(le+1):Te+=k.slice(F),Te.slice(1)}function ht(k){let V="",W=0;for(let ve=0;ve=65536?ve+=2:ve++){W=ft(k,ve);const F=ce[W];!F&&Re(W)?(V+=k[ve],W>=65536&&(V+=k[ve+1])):V+=F||ae(W)}return V}function ni(k,V,W){let ve="";const F=k.tag;for(let de=0,le=W.length;de"u"&&U(k,V,null,!1,!1))&&(ve!==""&&(ve+=","+(k.condenseFlow?"":" ")),ve+=k.dump)}k.tag=F,k.dump="["+ve+"]"}function Vn(k,V,W,ve){let F="";const de=k.tag;for(let le=0,Ae=W.length;le"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!ve||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let ve="";const F=k.tag,de=Object.keys(W);for(let le=0,Ae=de.length;le1024&&(Te+="? "),Te+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Te+=k.dump,ve+=Te))}k.tag=F,k.dump="{"+ve+"}"}function kt(k,V,W,ve){let F="";const de=k.tag,le=Object.keys(W);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Te=le.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?je+="?":je+="? "),je+=k.dump,Ve&&(je+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?je+=":":je+=": ",je+=k.dump,F+=je)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const ve=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=ve.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Te}return!0}}return!1}function U(k,V,W,ve,F,de,le){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Te=ve;ve&&(ve=k.flowLevel<0||k.flowLevel>V);const je=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(je&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(je&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")ve&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")ve&&k.dump.length!==0?(k.noArrayIndent&&!le&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&Be(k,k.dump,V,de,Te);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],ve=[];ue(k,W,ve);const F=ve.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const o of r){if(s===null||typeof s!="object"||!(o in s))throw new Error(`Reference not found: ${n}`);s=s[o]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const o=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return o[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:o,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),o?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],tf={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(tf),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function nf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...tf[t]]:Cs.filter(n=>t.some(r=>r===n||tf[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function ho(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(o=>typeof o=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function Ba(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const o={...ho(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete o[e]:o[e]=c,o.expand===void 0&&o.sidebarCollapsed===void 0&&o.theme===void 0&&o.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(o))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],o=e[r]??s?.default;if(o===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(o))throw new Error(`Invalid value for server variable ${r}: ${o}`);return o})}function rf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const o=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of o)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return rf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=rf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const o=r.requestBody,c=o?Object.keys(o.content||{})[0]:void 0;if(c){s.contentType=c;const u=o.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function sf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=sf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,o])=>`${s}=${cn(o)}`).join(","):r.flatMap(([s,o])=>[s,cn(o)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=sf(e),o=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(o);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[o(f),o(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=o(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=sf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([o,c])=>[`${t.name}[${o}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(o=>[t.name,cn(o)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const o=Object.entries(s);return r?o.map(([c,u])=>[c,cn(u)]):[[t.name,o.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,o){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,o))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=o[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=rf(t,e,n),o=s.servers[0],c=r.serverUrl||(o?wk(o,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const o=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)o.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&o.push(` --data-raw ${un(t.body)}`),o.join(` \\ +`)}if(e==="javascript"){const o={method:t.method};return n.length&&(o.headers=t.headers),t.body&&(o.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(o,null,2)}); +const data = await response.json();`}if(e==="python"){const o=["import requests","",`url = ${un(t.url)}`];return n.length&&o.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&o.push(`body = ${un(t.body)}`),o.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),o.join(` +`)}if(e==="go"){const o=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${o})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` +`)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[o,c]of n)r.push(` .header(${un(o)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var lf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,o=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=ae.value.length,ae=ae.next){var we=ae.value;if(j.length>O.length)return;if(!(we instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=ae.value.length;Re>=ne;)ae=ae.next,ne+=ae.value.length;if(ne-=ae.value.length,he=ne,ae.value instanceof f)continue;for(var Ce=ae;Ce!==j.tail&&(neM.reach&&(M.reach=$e);var ft=ae.prev;He&&(ft=v(j,ft,He),he+=He.length),w(j,ft,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(ae=v(j,ft,At),Je&&v(j,ae,Je),T>1){var bt={cause:G+","+B,reach:$e};g(O,j,R,ae.prev,he,bt),M&&bt.reach>M.reach&&(M.reach=bt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+o+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(o),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:o=!1})=>{const[c,u]=kd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${o?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:o=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(o.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(o);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:o})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:o},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:o})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:o})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function $a(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),o=Object.keys(r);return s.length===o.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function of(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const o=e(),c=of(o,r),u={key:r,value:String(s),enabled:!0};c>=0?o[c]=u:o.push(u)};return{get(r){const s=of(e(),r);return s>=0?e()[s].value:void 0},has(r){return of(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=$a(t.variables||{}),r=$a(t.collectionVariables||{}),s=$a(t.externalVariables||{}),o=$a(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(o,R)?n[R]=o[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return o[R]},has(R){return Object.prototype.hasOwnProperty.call(o,R)},set(R,_){const L=String(_);o[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete o[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(o,M)?o[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` -`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!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:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,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}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{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 n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.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 fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(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(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(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}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(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,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}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 n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` -`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;se.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",o=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${o}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const o=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>o.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:o}}function cf(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function Ia(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&Ia(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&Ia(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&Ia(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&Ia(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const o=Y0(n);if(o.length>0)throw new Error(`This request requires API host execution (${o.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=cf(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,o])=>({key:s,value:o})),body:t.body,contentType:cf(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:cf(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,o])=>({key:s,value:o,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function po(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const o=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return o&&!("$ref"in o)?o:void 0}function lC(t,e,n,r){const o=rC(t,e,n)?.security??t.security??[];if(!o.length)return;const c=o.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=o.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(o.find(f=>Object.keys(f).length===0)??o[0])}function oC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,o=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:o?.authorizationUrl,tokenUrl:o?.tokenUrl,scopes:n.length?n:Object.keys(o?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function aC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let o=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return o;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return o;if(!h)return{...o,auth:{type:"inherit"}};const g=oC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?o=X0(o,"Authorization"):g.type==="apiKey"&&g.in==="header"?o=X0(o,g.key):g.type==="apiKey"&&g.in==="query"&&(o=aC(o,g.key)),{...o,auth:g}):o}function uC(t,e,n,r,s){const o=B0(t,e,n,r);return{request:cC(t,e,n,r,o),serverUrl:r.serverUrl||s}}function Ha(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const uf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function df(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>df(e.key)?{...e,value:uf}:e)}function fC(t){return t?.map(e=>df(e[0])?[e[0],uf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const o=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return df(g)?`${h}=${encodeURIComponent(uf)}`:u}).join("&");return`${o}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Ha(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",o={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete o.responseBody,delete o.responseBodyTruncated,delete o.requestBodyTruncated),o});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Ha(n.auth)})),folders:t.folders.map(n=>({...n,auth:Ha(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Ha(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function mo(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function za(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function Ua(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!Ua(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Va(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function ff(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(ff(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Va(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(ff(t),JSON.stringify(wC(e))):sessionStorage.removeItem(ff(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(Ua))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(Ua))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(Ua))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Va(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Va(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Va(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const o=r.get(s.parentFolderId);(!o||o.collectionId!==s.collectionId||o.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const o=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(o.has(c)){s.parentFolderId=void 0;break}o.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!za(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!za(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!za(t,"runIndex")||!za(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,o])=>[s,o]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=mo();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function oy(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),o=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:o,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:o,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=o=>{if(o.length<=e)return e-=o.length,o;const c=o.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(o=>({...o,value:r(o.value)}))),s.formData&&(s.formData=s.formData.map(o=>({...o,value:r(o.value)}))),{request:s,truncated:n}}function ay(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),o={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:mo()};return{...t,history:[o,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),o=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!o.has(c.id);){if(o.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function hf(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function pf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),o=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,o=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});o=!0}if(!o)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:mo()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let o=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=o.filter(w=>w.key.trim()!==h);v.length!==o.length&&(o=v,c=!0);continue}const g=o.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];o[v]={...o[v],key:h,value:b,enabled:!0},g.length>1&&(o=o.filter((w,A)=>A===v||w.key.trim()!==h))}else o.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:o,updatedAt:mo()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=mo();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const o=e.transaction(tl,"readonly").objectStore(tl).get(t);o.onsuccess=()=>n(AC(t,oy(o.result))),o.onerror=()=>r(o.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const o=n.transaction(tl,"readwrite");o.objectStore(tl).put(Z0(e),t),o.oncomplete=()=>r(),o.onerror=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace")),o.onabort=()=>s(o.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),o=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{o.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,o.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function mf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,o=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:mf(O,.5),p95Ms:mf(O,.95),p99Ms:mf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),o=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:o===null?null:new Date(o).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,o=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const gf=zC();function VC(t){gf.record(t)}function FC(){return gf.snapshot()}function PC(){gf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function yf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=yf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Fa(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,o]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${o}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Pa(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&po(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,o=t.hostExecution?.preferHostExecution,c=o===!1?!1:t.preferHostExecution??s??o??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Pa({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:o}of n){const c=s.file;r.append(`formData[${o}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=yf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let o=yf(t.request),c=Fa(t.variables),u=Fa(t.collectionVariables);const f=Fa(t.externalVariables);let h=Fa(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(o=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(o={...o,auth:t.resolveAuth(o.auth)}),o=nC(o,c),w=(o.method||"GET").toUpperCase(),A=o.url;const[j,,,R]=Pa({request:o,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(o);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(o);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:o,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function bf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:o="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":o,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Ya(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const o of e)n+=String.fromCharCode(o);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function oN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),o=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",o),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Ya(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function aN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||aN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const o=vy(48),c=await oN(o);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:o}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,o=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:o,scope:typeof n.scope=="string"?n.scope:void 0}}async function Ka(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},o=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&o?s.Authorization=`Basic ${lN(`${o}:${t.clientSecret||""}`)}`:(o&&e.set("client_id",o),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),o=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-osetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Ya(t);return v&&b.set("scope",v),Ka(t,b,r)}const s=await cN(t,e.windowObject),o=await dN(s,e);if((o.searchParams.get("state")||new URLSearchParams(o.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(o.hash.replace(/^#/,"")),f=o.searchParams.get("error")||u.get("error");if(f){const b=o.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=o.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Ka(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Ya(t);return s&&r.set("scope",s),Ka(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,o]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{o(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{o(!1)}},w=async()=>{o(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{o(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},xf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:o,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>o(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>o({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:o}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>o({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>o({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>o({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>o({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>o({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>o({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>o({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>o({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>o({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>o({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>o({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>o({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>o({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>o({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>o({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>o({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>o({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>o({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>o({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>o({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>o({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let vf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=wf(t,e);for(e+=jy(r);e=0&&Ay(wf(t,c));)o++,c-=2;if(o%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new go(this),o=new go(e);for(let c=n,u=n;;){if(s.next(c),o.next(c),c=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new go(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.text[o],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let o=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ga(o.text,c.text.slice(),0,o.length);if(u.length<=32)r.push(new Vt(u,c.length+o.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ga(this.text,Ga(r.text,Ey(this.text,0,e)),n),o=this.length+r.length-(n-e);return s.length<=32?new Vt(s,o):Hi.from(Vt.split(s,[]),o)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;o<=n&&ce&&c&&(s+=r),eo&&(s+=u.slice(Math.max(0,e-o),n-o)),o=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let o of e)r.push(o),s+=o.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let o=0;;o++){let c=this.children[o],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let o=0,c=0;c<=n&&o=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=o&&n<=u){let f=c.replace(e-o,n-o,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let o=0,c=0;oe&&o&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,o,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,o+=n){if(s==c||o==u)return r;let f=this.children[s],h=e.children[o];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),o=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>o&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ga(t,e,n=0,r=1e9){for(let s=0,o=0,c=!0;o=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],o=this.offsets[r],c=o>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new go(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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!=""}}class My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},go.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const Sf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return o+(e-s);o+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?o:o+f;o+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Af(this,(n,r,s,o,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return kf(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,o=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,o.text),o.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],o=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||Sf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(o,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,o,g,b),s=h,o=g}}}function kf(t,e,n,r=!1){let s=[],o=r?[]:null,c=new yo(t),u=new yo(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),o.forward2(f),c.forward(f)}}}}class yo{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].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)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-o.from),n=e.indexOf(r);for(let s=1;so.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Cf=0;class Ue{constructor(e,n,r,s,o){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=Cf++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Nf),!!e.static,e.enables)}of(e){return new Xa([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xa(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Nf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Xa{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=Cf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,o=this.id,c=e[o]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Tf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[o];if(A!=null){let C=Za(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),o=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Ja).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let o=r.values[n],c=this.updateF(o,s);return this.compareF(o,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let o=r.facet(Ja),c=s.facet(Ja),u;return(u=o.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Ja.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function bo(t){return e=>new Ly(e,t)}const Qa={highest:bo(Ns.highest),high:bo(Ns.high),default:bo(Ns.default),low:bo(Ns.low),lowest:bo(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new jf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Wa{constructor(e,n,r,s,o,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=o,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],o=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(o[v.facet.id]||(o[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in o){let w=o[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Nf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Wa(e,c,b,u,f,o)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function o(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof jf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)o(h,u);else if(c instanceof jf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),o(h,u)}else if(c instanceof Ly)o(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&o(c.provides,u);else if(c instanceof Xa)r[u].push(c),c.facet.extensions&&o(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(h,u)}}return o(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function xo(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Za(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),Ef=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let o=s.map(n);o&&r.push(o)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,o,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=o,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),o.some(u=>u.type==rn.time)||(this.annotations=o.concat(rn.time.of(Date.now())))}static create(e,n,r,s,o,c){return new rn(e,n,r,s,o,c)}get newDoc(){return this._doc||(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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let o,c;if(r=t[r]))o=t[r++],c=t[r++];else if(s=0;s--){let o=r[s](t);o instanceof rn?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof rn?t=o[0]:t=Vy(e,sl(o),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let o=n[s](t);o&&Object.keys(o).length&&(r=Uy(r,Of(e,o,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Mf;try{Mf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Mf)return Mf.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,o,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let o;n?o=e.startState.values.slice():(n=Wa.resolve(r,s,this),o=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(Ef)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),o=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Wa.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||Sf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(Ef)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(o,c)=>c.create(o),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>n.length?r:n[o-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let o of this.facet(qy))for(let c of o(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(o(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Rf(t,e,n={}){let r={};for(let s of t)for(let o of Object.keys(s)){let c=s[o],u=r[o];if(u===void 0)r[o]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,o))r[o]=n[o](u,c);else throw new Error("Config merge conflict for field "+o)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return _f.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Df(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let _f=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function Lf(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class qf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let o=r?this.to:this.from;for(let c=s,u=o.length;;){if(c==u)return c;let f=c+u>>1,h=o[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let o=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,o);oE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}o(C,E,v)}}return{mapped:c.length?new qf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:o=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(Lf)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new vo;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new vo),o.addRange(f,h,g,!1)};for(let f=0;f=o&&e<=o+c.length&&c.between(o,e-o,n-o,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return wo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return wo.from(e).goto(n)}static compare(e,n,r,s,o=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=o),f=Fy(c,u,r),h=new So(c,f,o),g=new So(u,f,o);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let o=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(o.length!=c.length)return!1;if(!o.length)return!0;let u=Fy(o,c),f=new So(o,u,0).goto(r),h=new So(c,u,0).goto(r);for(;;){if(f.to!=h.to||!$f(f.active,h.active)||f.point&&(!h.point||!Df(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,o=-1){let c=new So(e,null,o).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new vo;for(let s of e instanceof _f?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(Lf);e=r}return t}mt.empty.nextLayer=mt.empty;class vo{finishChunk(e){this.chunks.push(new qf(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(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new vo)).addRange(e,n,r,s)}addInner(e,n,r,s){let o=e-this.lastTo||r.startSide-this.last.endSide;if(s&&o<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let o of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,o));return s.length==1?s[0]:new wo(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)Bf(this.heap,r);(this.to-e||this.value.endSide-n)<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(),Bf(this.heap,0)}}}function Bf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class So{constructor(e,n,r){this.minPoint=r,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=wo.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){ec(this.active,e),ec(this.activeTo,e),ec(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:o}=this.cursor;for(;n0;)n++;tc(this.active,n,r),tc(this.activeTo,n,s),tc(this.activeRank,n,o),e&&tc(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&ec(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,o){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!o.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Df(t.point,n.point)&&$f(t.activeForPoint(t.to),n.activeForPoint(n.to))||o.comparePoint(u,A,t.point,n.point),g=!1):(g&&o.boundChange(u),A>u&&!$f(t.active,n.active)&&o.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function $f(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;o+=t.charCodeAt(s)==9?n-o%n:1,s=kn(t,s)}return t.length}const If="ͼ",Gy=typeof Symbol>"u"?"__"+If:Symbol.for(If),Hf=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ol{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function o(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))o(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");o(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)o(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,If+e.toString(36)}static mount(e,n,r){let s=e[Hf],o=r&&r.nonce;s?o&&s.setNonce(o):s=new IN(e,o),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let o=Jy.get(r);if(o)return e[Hf]=o;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Hf]=this}mount(e,n){let r=this.sheet,s=0,o=0;for(let c=0;c-1&&(this.modules.splice(f,1),o--,f=-1),f==-1){if(this.modules.splice(o++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Ao[dn]=String.fromCharCode(dn);for(var zf in $r)Ao.hasOwnProperty(zf)||(Ao[zf]=$r[zf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ao:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Uf=typeof document<"u"?document:{documentElement:{style:{}}};const Vf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Ff=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),ic=!!(Qy||Ff||Vf),Wy=!ic&&/gecko\/(\d+)/i.test(Dn.userAgent),Pf=!ic&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in Uf.documentElement.style,Yf=!ic&&/Apple Computer/.test(Dn.vendor),eb=Yf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:ic,ie_version:Qy?Uf.documentMode||6:Ff?+Ff[1]:Vf?+Vf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Pf,chrome_version:Pf?+Pf[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Yf,safari_version:Yf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:Uf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Kf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const rc=Object.create(null);function Gf(t,e,n){if(t==e)return!0;t||(t=rc),e||(e=rc);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let o of r)if(o!=n&&(s.indexOf(o)==-1||t[o]!==e[o]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:o,end:c}=nb(e,n);r=(o?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new Co(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}on.none=mt.empty;class ko extends on{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Kf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||rc}eq(e){return this==e||e instanceof ko&&this.tagName==e.tagName&&Gf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}ko.prototype.point=!1;class Co extends on{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Co&&this.spec.class==e.spec.class&&Gf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Co.prototype.mapMode=Wn.TrackBefore,Co.prototype.point=!0;class js extends on{constructor(e,n,r,s,o,c){super(n,r,o,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function al(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class No extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof No&&this.tagName==e.tagName&&Gf(this.attributes,e.attributes)}static create(e){return new No(e.tagName,e.attributes||rc,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}No.prototype.startSide=No.prototype.endSide=-1;function To(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Xf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function jo(t,e){if(!e.anchorNode)return!1;try{return Xf(t,e.anchorNode)}catch{return!1}}function lc(t){return t.nodeType==3?Oo(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Eo(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function oc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,o,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+o)):e.right>v.right-o&&(E=e.right-v.right+o,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let o=t.parentNode;o&&!(o==n.body||(!e||r)&&s);)if(o.nodeType==1)!s&&o.scrollHeight>o.clientHeight&&(s=o),e&&!r&&o.scrollWidth>o.clientWidth&&(r=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:r,y:s}}class GN{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:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ob(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ab(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ob(e))}let cb;function Oo(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),o.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!oc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(o<0||(s!=0?s<0?u.fromn:e[o].level>u.level))&&(o=c)}}if(o<0)throw new RangeError("Index out of range");return o}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?o:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,o=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else o=h,f++}}}function Wf(t,e,n,r,s,o,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Zf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Wf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>o[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==o[h-1].to){if(b)break e;let C=o[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&o[D-1].to==E)E=o[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Zf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var o;let c=r.head-t.from,u=Vi.find(e,c,(o=r.bidiLevel)!==null&&o!==void 0?o:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,o,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=o,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const cc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(uc.of(h=>{let g=h.plugin(u);return g?c(g):on.none})),o&&f.push(o(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class ih{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.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),rh=Ue.define(),uc=Ue.define(),Eb=Ue.define(),sh=Ue.define(),Mo=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(o=>o instanceof Function?o(t):o),s=[];return mt.spans(r,e.from,e.to,{point(){},span(o,c,u,f){let h=o-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let o of t.state.facet(Rb)){let c=o(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ro=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(o,c,u,f))),this.changedRanges=s}static create(e,n,r){return new dc(e,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}}const oT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return oT}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 n=this.domAttrs;n&&VN(this.dom,n)}}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,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),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 hc)return e;return null}static get(e){return e.cmTile}}class fc extends Ht{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 n=this.dom,r=null,s,o=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,o&&s!=u.dom&&(o.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,o&&s&&(o.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hc extends fc{constructor(e,n){super(n),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 n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,o=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&o++,s=n.pop()}else{let c=r.children[s++];if(c instanceof or)n.push(s),r=c,s=0;else{let u=o+c.length,f=e(c,o);if(f!==void 0)return f;o=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,o,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,c=e-f)}}),!r&&!o)throw new Error("No tile at position "+e);return r&&n<0||!o?{tile:r,offset:s}:{tile:o,offset:c}}}class or extends fc{constructor(e,n){super(e),this.wrapper=n}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(e,n){let r=new or(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends fc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,o=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,o=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?o:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):aT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:o}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,o)):s.domPosFor(o,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function aT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=lc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let o=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(o--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}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,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let o=this.dom.getClientRects(),c=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;c=o[f],!(e>0?f==0:f==o.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:o,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(o==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:o}=u.pop(),o++}else{let f=s.children[o],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(lh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(lh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let o=Ht.get(e.text);o&&this.cache.reused.set(o,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let o=this.ensureMarks(n,r);!s&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).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 n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}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,n){var r;let s=this.curLine;for(let o=e.length-1;o>=0;o--){let c=e[o],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(oh,0,32)||new Rs(oh.toDOM(),0,oh,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){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(o),n=o}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(pc,void 0,1);return r&&(r.flags=n),r||new pc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{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:s,lineBreak:o,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return o?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const mc=[Rs,fl,Ms,Hn,pc,or,hc];for(let t=0;t[]),this.index=mc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,o=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,o=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,o+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=o=0):c instanceof Hn&&(s.shift(),o=Math.min(o,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,o=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>o),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let o=Ht.get(s);if(s==this.view.contentDOM)break;o instanceof Hn?n.push(o):o?.isLine()?r=o:o instanceof or||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new ko({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Kf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function lh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends sc{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}}hl.inline=new hl("span"),hl.block=new hl("div");const oh=new class extends sc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=on.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 hc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let o=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Oe.ie||Oe.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),o&&!r.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(r=o.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.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 o=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||r.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&jo(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(o||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!Eo(h.node,h.offset,b.anchorNode,b.anchorOffset)||!Eo(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=To(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&Eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=To(e.root),{anchorNode:s,anchorOffset:o}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,o)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let o;if(e==r.dom)o=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?o=e:o=e.nextSibling}if(o==r.dom.firstChild)return s;for(;o&&!Ht.get(o);)o=o.nextSibling;if(!o)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,o=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(o=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,o=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(o&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:o}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof ch?null:s.coordsInWidget(o,n,!0):s.coordsIn(o,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(o,c){if(o.isComposite())for(let u of o.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(o.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof or)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?lc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=o,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=lc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,o;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=lc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,o=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:o}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let o=s==n.viewports.length?null:n.viewports[s],c=o?o.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(on.replace({widget:new ch(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!o)break;r=o.to+1}return on.set(e)}updateDeco(){let e=1,n=this.view.state.facet(uc).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),r=!1,s=this.view.state.facet(sh).map((o,c)=>{let u=typeof o=="function";return u&&(r=!0),u?o(this.view):o});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Db(this.view),c={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),o=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=r,!o)return null;let c=e-o.offset;return{from:c,to:c+o.node.nodeValue.length,node:o.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:o,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(o),f.mapPos(c),o,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class ch extends sc{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 jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(s.length==0)return ke.cursor(e);o==0?n=1:o==s.length&&(n=-1);let c=o,u=o;n<0?c=kn(s.text,o,!1):u=kn(s.text,o);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);o+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,o,t.state.tabSize)}function uh(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let o of r.type){if(o.from>e)break;if(!(o.toe)return o;(!s||o.type==fn.Text&&(s.type!=o.type||(n<0?o.frome)))&&(s=o)}}return s||r}return r}function OT(t,e,n,r){let s=uh(t,e.head,e.assoc||-1),o=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(o){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(o.top+o.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,o,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),o=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return o=>{let c=r(o);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,o=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=o<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(o<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*o,E=fh(t,{x:b,y:C},!1,o);if(n?C>f.bottom:Cu:O{if(e>o&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+o:v.bottom>=f+o))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=o&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let o=0;o{let c=r[o]-n,u=r[o+1]-n;return Oo(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Oo(f.dom,0,f.length)).getClientRects()}),o=e.children[s.i],c=r[s.i];return o.isText()?this.scanText(o,c):o.isComposite()?this.scanTile(o,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let o=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:oc(s))||oc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>o)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,c=1,u;if(this.lineSeparator?(o=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(o=u.index,c=u[0].length),this.append(n.slice(r,o<0?n.length:o)),o<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=o+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:o,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=o||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!Xf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Xf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,o=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,o=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:o,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,o=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=o.from,g=null;(c===8||Oe.android&&e.text.length=u&&o.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&b.slice(o.to-u)==e.text.slice(v=e.text.length-(b.length-(o.to-u)))?n={from:o.from,to:o.to,insert:gt.of(e.text.slice(o.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||gc(r,o))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(o.from).toDate.now()-50?n={from:o.from,to:o.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:o.from,to:o.to,insert:gt.of([" "])}),n)return hh(t,n,r,c);if(r&&!gc(r,o)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Mo).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function hh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,o,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,o=s.selection.main,c=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=o.frome.to?s.sliceDoc(e.to,o.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(o.head);let w=o.to-e.to;r=s.changeByRange(A=>{if(A.from==o.from&&A.to==o.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-o.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),o=0;for(;o0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,o-Math.min(c,u));n-=c+f-o}if(c=c?o-n:0;o-=f,u=o+(u-c),c=o}else if(u=u?o-n:0;o-=f,c=o+(c-u),u=o}return{from:o,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||o!=r)&&e.push(new zb(s,o))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function gc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let o in n)if(o!="scroll"){let c=!n[o].handlers.length,u=r[o];u&&c!=!u.handlers.length&&(s.removeEventListener(o,this.handleEvent),u=null),u||s.addEventListener(o,this.handleEvent,{passive:c})}for(let o in r)o!="scroll"&&!n[o]&&s.removeEventListener(o,this.handleEvent);this.handlers=n}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&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.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 UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,o=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],yc=6;function bc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Mo).map(c=>c(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==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&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,o=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+yc?n=-bc(s-e.clientX):e.clientX+f.right>=c-yc&&(n=bc(e.clientX-c)),e.clientY-f.top<=o+yc?r=-bc(o-e.clientY):e.clientY+f.bottom>=u-yc&&(r=bc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=To(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function xc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=xc(t.state,th,e);let{state:n}=t,r,s=1,o=n.toText(e),c=o.lines==n.selection.ranges.length;if(ph!=null&&n.selection.ranges.every(f=>f.empty)&&ph==o.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?o.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=o.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(o);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ab(t.contentDOM);let o=t.root.activeElement;o&&!o.contains(t.contentDOM)&&o.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),o=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:o.from,u=s?s.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(o){o.docChanged&&(n.pos=o.changes.mapPos(n.pos),s=s.map(o.changes))},get(o,c,u){let f=t.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let o=s.posAtStart,c=o+s.length;(o>=n.to||c<=n.from)&&(n=ke.undirectionalRange(o,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",xc(t.state,nh,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=xc(t.state,th,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,c=r&&o&>(t,e)?{from:o.from,to:o.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,o=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),o()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let c=t.doc.lineAt(o);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:xc(t,nh,e.join(t.lineBreak)),ranges:n,linewise:r}}let ph=null;Mi.copy=Mi.cut=(t,e)=>{if(!jo(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;ph=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=Gb?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let o=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(o&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return hh(t,{from:f,to:h,insert:t.state.toText(o)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(o=>o.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>o+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ox(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}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 lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=o,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>vc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let o=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=o.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:o.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fo*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(o>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,o-=u.size}else break;else if(s=o&&c(this.lineAt(0,Rt.ByPos,r,s,o))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ax{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||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:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,o=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);c=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else c=this.height/o;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:o,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let o=r[r.length-1];o instanceof hn?r[r.length-1]=new hn(o.length+s):r.push(null,new hn(s-1))}if(e>0){let o=r[0];o instanceof hn?r[0]=new hn(e+o.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let o=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=o&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=vc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=o&&c.push(null,new hn(o-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=vc||Math.abs(f-this.heightMetrics(e,n).perLine)>=vc)&&(ml=!0),wc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class oj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let o=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,o).join(h)}forEachLine(e,n,r,s,o,c){let u=s+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,o);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let o=[];e>0&&this.decomposeLeft(e,o);let c=o.length;for(let u of r)o.push(u);if(e>0&&cx(o,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=wc(this.left,e),this.right=wc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:o,right:c}=this,u=n+o.length+this.break,f=null;return s&&s.from<=n+o.length&&s.more?f=o=o.updateHeight(e,n,r,s):o.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(o,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const aj=5;class mh{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=aj)&&this.addLineDeco(s,o,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();o=Math.max(o,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:o-n.left,right:Math.max(o,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class gh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=on.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:o,to:c})=>s>=o&&s<=c)){let{from:o,to:c}=this.lineBlockAt(s);e.push(new Sc(o,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new yh(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(_o(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,o=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ox(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,o=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(o,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ox();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,o=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new Sc(s.lineAt(c-r*1e3,Rt.ByHeight,o,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,o,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,o,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&o>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new gh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(o,c){r.push({from:o,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||_o(this.heightMap.lineAt(e,Rt.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(n=>n.top<=e&&n.bottom>=e)||_o(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return _o(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}}class Sc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,o=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),o+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:o,to:c}=e[s],u=c-o;if(r<=u)return o+r;r-=u}}function kc(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(uc).filter(r=>typeof r!="function"),n=t.facet(sh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class yh{constructor(e,n,r){let s=0,o=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-o)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),o=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let o=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function _o(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>_o(s,e)):t._content)}const Cc=Ue.define({combine:t=>t.join(" ")}),bh=Ue.define({combine:t=>t.indexOf(!0)>-1}),xh=ol.newName(),hx=ol.newName(),px=ol.newName(),mx={"&light":"."+hx,"&dark":"."+px};function vh(t,e,n){return new ol(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=vh("."+xh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,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(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),wh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!jo(this.dom,s))return;let o=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&Eo(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=To(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=jo(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&cl(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{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 n=-1,r=-1,s=!1;for(let o of e){let c=this.readMutation(o);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&jo(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!gc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return Eo(c.node,c.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=r=>{let s=e.state.selection.main,{anchor:o,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&othis.to&&(f=o);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));gc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);hh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],o=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let o of r.getTextFormats()){let c=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),h=this.toEditorPos(o.rangeEnd);if(f{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:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=To(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((o,c,u,f,h)=>{if(r)return;let g=h.length-(c-o);if(s&&c>=s.to)if(s.from==o&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(o+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(othis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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={}){var n;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:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(o=>r(o,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(cc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new ih(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,o=this.state;for(let v of e){if(v.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=v.state}if(this.destroyed){this.viewState.state=o;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(o,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(g=null)):this.observer.clear(),o.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(o);s=dc.create(this,o,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(cc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Nc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ro)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Cc)!=s.state.facet(Cc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(eh))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new ih(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let o of r){let c=n.indexOf(o);if(c<0)s.push(new ih(o));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))o=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);o=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=dc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?o<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(eh))f(n)}get themeClasses(){return xh+" "+(this.state.facet(bh)?px:hx)+" "+this.state.facet(Cc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,rh,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),o=tb(this.dom,this.editorAttrs,e);return s||o});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ro);let e=this.state.facet(Xe.cspNonce);ol.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;nr.plugin==e)||null),n&&n.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,n,r){return dh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return dh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),o=r[n?r.length-1:0];return ke.cursor(o.side(n,s)+e.from,o.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return dh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=fh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),fh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,o.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==n&&(o.fresh||mb(o.isolates,r=Mb(this,e))))return o.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Nc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ab(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,n={}){var r,s,o,c;return cc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(o=n.yMargin)!==null&&o!==void 0?o:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return cc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!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 lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=ol.newName(),s=[Cc.of(r),Ro.of(vh(`.${r}`,e))];return n&&n.dark&&s.push(bh.of(!0)),s}static baseTheme(e){return Qa.lowest(Ro.of(vh("."+xh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ro,Xe.inputHandler=Sb,Xe.clipboardInputFilter=th,Xe.clipboardOutputFilter=nh,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=eh,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=uc,Xe.blockWrappers=Eb,Xe.outerDecorations=sh,Xe.atomicRanges=Mo,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=bh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=rh,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Nc{constructor(e,n,r,s,o,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=o,this.order=c}static update(e,n){if(n.empty&&!e.some(o=>o.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let o=Math.max(0,e.length-10);o=0;s--){let o=r[s],c=typeof o=="function"?o(t):o;c&&Kf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,o,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},o=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,Sh))}let f=c[e]||c.key;if(f)for(let h of u)o(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&o(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let Sh=null;function Ej(t,e,n,r){Sh=e;let s=UN(e),o=kN(s,0),c=CN(o)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Tc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Tc(A,e,!0)])||e.shiftKey&&(C=Ao[e.keyCode])!=s&&C!=A&&v(w[u+Tc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Tc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),Sh=null,f}class Ds{constructor(e,n,r,s,o){this.className=e,this.left=n,this.top=r,this.width=s,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let o=Sx(e);return[new Ds(n,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let o=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:o.left+1,y:c}),f=t.posAtCoords({x:o.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),o=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=uh(t,r,1),A=uh(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;we>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(we,q),L==null&&we>=be,ae.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(jc)!=e.state.facet(jc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(jc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const jc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),jc.of(t)]}const gl=Ue.define({combine(t){return Rf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(o&&Oe.ios&&n.iosSelectionHandles)){let c=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let o of Ds.forRange(t,"cm-selectionBackground",s))e.push(o);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Qa.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=on.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return on.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const Ec=Ue.define(),Hj=Ue.define(),Oc=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Oc).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.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(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Ec),this.view.viewport.from),r=[],s=this.gutters.map(o=>new Vj(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let c=!0;for(let u of o.type)if(u.type==fn.Text&&c){Ah(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(o.type==fn.Text){Ah(n,r,o.from);for(let c of s)c.line(this.view,o,r)}else if(o.widget)for(let c of s)c.widget(this.view,o);for(let o of s)o.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Oc),n=t.state.facet(Oc),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Ec),t.state.facet(Ec),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let o of n){let c=e.indexOf(o);c<0?s.push(new Ox(this.view,o)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let o of this.gutters)o.dom.remove(),s.indexOf(o)<0&&o.destroy();for(let o of s)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Ah(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,o=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,o,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,o,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Ah(this.cursor,s,n.from),r.length&&(s=s.concat(r));let o=this.gutter.config.lineMarker(e,n,s);o&&s.unshift(o);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let o of e.state.facet(Hj)){let c=o(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let o=s.target,c;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let o=0,c=0;;){let u=c,f=oo(u,f,h)||c(u,f,h):c}return r}})}});class kh extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ch(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Oc.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new kh(Ch(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let o=s(e,n,r);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new kh(Ch(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=Ch(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new kh(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Nh{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class Lo{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(s)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return s}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 n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),o=-1;o<(s?s.length:0);o++){let c=n[o<0?r.name:s[o]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Mc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,o){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,o&&o.length){this.props=Object.create(null);for(let[c,u]of o)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=Lo.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Eh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Mc.get(this)||this.topNode,o=new Eh(s);return o.moveTo(e,n),Mc.set(this,o._tree),o}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=qo(Mc.get(this)||this.topNode,e,n,!1);return Mc.set(this,r),r}resolveInner(e,n=0){let r=qo(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:o=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=o&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Mh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Th{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Th(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,o=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function qo(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(o&Pt.EnterBracketed&&g instanceof pn&&(v=Lo.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(o&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(o&Pt.IncludeAnonymous||!g.type.isAnonymous||Oh(g)){let w;if(!(o&Pt.IgnoreMounts)&&(w=Lo.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return o&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,o)}}}if(o&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=Lo.get(this._tree))&&s.overlay){let o=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=o:u=o:f>o))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,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 $x(t,e,n,r){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return o}for(;;){if(r!=null&&s.type.is(r))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return r==null?o:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,o=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,o=r.buffer[this.index+3];if(o>s){let c=r.buffer[this.index+1];e.push(r.slice(s,o,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let o=1;on.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+o.from,-1,o);(s||(s=[r])).push(qo(u,e,n,!1))}}return s?Ix(s):r}class Eh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.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,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(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,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,o=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<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 n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let o=n+e,c=e<0?-1:r._tree.children.length;o!=c;o+=e){let u=r._tree.children[o];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Oh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=o+1;break e}s=this.stack[--o]}for(let s=r;s=0;o--){if(o<0)return jh(this._tree,e,s);let c=r[n.buffer[this.stack[o]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Oh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Oh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:o=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Th(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=o[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],ae,he,we=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);ae=new Ur(T,be-he.start,r),we=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);ae=Mh(J,z,me,0,z.length,0,be-ee,qe,qe)}else ae=C(J,z,me,be-ee,ge-be,q)}M.push(ae),G.push(we)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(yt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[yt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[yt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Rc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Rc(t,r)}Hx.set(e,n)}return n}function Mh(t,e,n,r,s,o,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Mh(t,A,C,R,j,_,M,null,f))}v.push(_+O-o)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,o=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(o?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let o of n)o.to>e.length&&s.push(o);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],o=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=onew Nh(s.from,s.to)):[new Nh(0,0)]:[new Nh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let o=s.advance();if(o)return o}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let o of n.set)s.set.push(o);return s}static defineModifier(e){let n=new Dc(e);return r=>r.modified.indexOf(n)>-1?r:Dc.get(r.base||r,r.modified.concat(n).sort((s,o)=>s.id-o.id))}}let lE=0;class Dc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&oE(n,u.modified));if(r)return r;let s=[],o=new yi(e.name,s,e,n);for(let u of n)u.instances.push(o);let c=aE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Dc.get(u,f));return o}}function oE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function aE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let o=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(o.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=o.length-1,h=o[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new _c(r,c,f>0?o.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let o=new _c(s.tags,s.mode,s.context);n?n.next=o:r=o,n=o}return r}});class _c{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of o)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const Ee=yi.define,Lc=Ee(),Fr=Ee(),zx=Ee(Fr),Ux=Ee(Fr),Pr=Ee(),qc=Ee(Pr),Rh=Ee(Pr),Yi=Ee(),Ls=Ee(Yi),Ki=Ee(),Gi=Ee(),Dh=Ee(),Bo=Ee(Dh),Bc=Ee(),rt={comment:Lc,lineComment:Ee(Lc),blockComment:Ee(Lc),docComment:Ee(Lc),name:Fr,variableName:Ee(Fr),typeName:zx,tagName:Ee(zx),propertyName:Ux,attributeName:Ee(Ux),className:Ee(Fr),labelName:Ee(Fr),namespace:Ee(Fr),macroName:Ee(Fr),literal:Pr,string:qc,docString:Ee(qc),character:Ee(qc),attributeValue:Ee(qc),number:Rh,integer:Ee(Rh),float:Ee(Rh),bool:Ee(Pr),regexp:Ee(Pr),escape:Ee(Pr),color:Ee(Pr),url:Ee(Pr),keyword:Ki,self:Ee(Ki),null:Ee(Ki),atom:Ee(Ki),unit:Ee(Ki),modifier:Ee(Ki),operatorKeyword:Ee(Ki),controlKeyword:Ee(Ki),definitionKeyword:Ee(Ki),moduleKeyword:Ee(Ki),operator:Gi,derefOperator:Ee(Gi),arithmeticOperator:Ee(Gi),logicOperator:Ee(Gi),bitwiseOperator:Ee(Gi),compareOperator:Ee(Gi),updateOperator:Ee(Gi),definitionOperator:Ee(Gi),typeOperator:Ee(Gi),controlOperator:Ee(Gi),punctuation:Dh,separator:Ee(Dh),bracket:Bo,angleBracket:Ee(Bo),squareBracket:Ee(Bo),paren:Ee(Bo),brace:Ee(Bo),content:Yi,heading:Ls,heading1:Ee(Ls),heading2:Ee(Ls),heading3:Ee(Ls),heading4:Ee(Ls),heading5:Ee(Ls),heading6:Ee(Ls),contentSeparator:Ee(Yi),list:Ee(Yi),quote:Ee(Yi),emphasis:Ee(Yi),strong:Ee(Yi),link:Ee(Yi),monospace:Ee(Yi),strikethrough:Ee(Yi),inserted:Ee(),deleted:Ee(),changed:Ee(),invalid:Ee(),meta:Bc,documentMeta:Ee(Bc),annotation:Ee(Bc),processingInstruction:Ee(Bc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var _h;const $c=new yt,fE=new yt;class ar{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((o,c,u)=>{let f=Vx(o,c,u),h=f.type.prop($c);if(!h)return[];let g=o.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,o)){let A=o.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop($c)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(o,c)=>{if(o.prop($c)==this.data){r.push({from:c,to:c+o.length});return}let u=o.prop(yt.mounted);if(u){if(u.tree.prop($c)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+o.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let $o=null;class Ic{constructor(e,n,r=[],s,o,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=o,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Ic(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=$o;$o=this;try{return e()}finally{$o=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:o,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,o=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let o=s[0].from,c=s[s.length-1].to;return{parsedPos:o,advance(){let f=$o;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return $o}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Ic.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}ar.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(ar.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Lh=typeof navigator<"u"&&(!((_h=navigator.scheduling)===null||_h===void 0)&&_h.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=o.context.work(()=>Lh&&Lh()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ar.setState.of(new bl(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[ar.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),qh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Hc(t){let e=t.facet(qh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function zc(t,e){let n="",r=t.tabSize,s=t.facet(qh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let o=0;o=e?yE(t,n,e):null}class Uc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Hc(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:o}=this.options;return s!=null&&s>=r.from&&s<=r.to?o&&s==e?{text:"",from:e}:(n<0?s-1&&(o+=c-this.countColumn(r,r.search(/\S|$/))),o}countColumn(e,n=e.length){return nc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),o=this.options.overrideIndentation;if(o){let c=o(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let o=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)o.push(c);for(let c=o.length-1;c>=0;c--)r={node:o[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(Bh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,o=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,o&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class Bh extends Uc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Bh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(n.from),c=s==null||s<=o.from?o.to:Math.min(o.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let o=t.textAfter,c=o.match(/^\s*/)[0].length,u=r&&o.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function $h(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function Ih(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,o=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=$h(f.type,n,o);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,o)}}return jE(t,e,n,c,u.type,s,o)}function TE(t,e,n,r,s,o,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&o.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=o;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]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"]])OE[t]=ME(EE,e);function Hh(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Hh(h,`Modifier ${h} used at start of tag`):f.length?Hh(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Hh(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),o=Jx[s];if(o)return o.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Uh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function zh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=zh($E,0),_E=zh(Qx,0),LE=zh((t,e)=>Qx(t,e,BE(e)),0);function Uh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Io=50;function qE(t,{open:e,close:n},r,s){let o=t.sliceDoc(r-Io,r),c=t.sliceDoc(s,s+Io),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(c)[0].length,h=o.length-u;if(o.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*Io?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+Io),b=t.sliceDoc(s-Io,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let o=e.length-1;o>=0&&e[o].to>r.from?e[o].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(o=>Uh(e,o.from).block);if(!r.every(o=>o))return null;let s=n.map((o,c)=>qE(e,r[c],o.from,o.to));if(t!=2&&!s.every(o=>o))return{changes:e.changes(n.map((o,c)=>s[c]?[]:[{from:o.from,insert:r[c].open+" "},{from:o.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(o=>o)){let o=[];for(let c=0,u;cs&&(o==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;vo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&o.push({from:u.from+h,insert:f+" "});let c=e.changes(o);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,o.push({from:h,to:g})}return{changes:o}}return null}const Vh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Rf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Vh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Fc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return o?t=t.addChanges(o,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Fh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Vc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let o=s.pop(t,n,e);return o?(r(o),!0):!1}}const ev=Vc(0,!1),Fh=Vc(1,!1),UE=Vc(0,!0),VE=Vc(1,!0);class zn{constructor(e,n,r,s,o){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=o}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let o=s(e);o.length&&(r=r.concat(o))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Fc(t,e,n,r){let s=e+1>n+20?e-n-1:0,o=t.slice(s,e);return o.push(r),o}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,o)=>n.push(s,o)),e.iterChangedRanges((s,o,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Fc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Ph(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let o=t.slice(0,n);return o[n-1]=s,o}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),o=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(o):o;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(o),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,o){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Pc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function ov(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Pc(n,e))}const JE=t=>ov(t,!Nn(t)),QE=t=>ov(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Yc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let o=r.type.prop(s),c,u;return o&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Yc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Yc(t.state,e,Nn(t)));function av(t,e){return _i(t,n=>{if(!n.empty)return Pc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>av(t,!1),uv=t=>av(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Pc(c,e));if(s.eq(r.selection))return!1;let o;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Yh=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let o=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&e.head!=r.from+o&&(s=ke.cursor(r.from+o))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function oO(t,e,n){let r=!1,s=wl(t.selection,o=>{let c=vl(t,o.head,-1)||vl(t,o.head,1)||o.head>0&&vl(t,o.head-1,1)||o.headoO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let o=n(s);return ke.range(s.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Yc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Yc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Gc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),o=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let o of n.selection.ranges){let c=n.doc.lineAt(o.head);if(e?c.to0)for(let u=o;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ho(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(o=>{let{from:c,to:u}=o;if(c==u){let f=e(o);fc&&(n="delete.forward",f=Kc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Kc(t,c,!1),u=Kc(t,u,!0);return c==u?{range:o}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,o)=>{se&&(e=n?o:s)});return e}const Ev=(t,e,n)=>Ho(t,r=>{let s=r.from,{state:o}=t,c=o.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ho(t,n=>{let r=n.head,{state:s}=t,o=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?o.to:o.from)){r==n.head&&o.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(o.text,r-o.from,e)+o.from,h=o.text.slice(Math.min(r,f)-o.from,Math.max(r,f)-o.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ho(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headHo(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ho(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,o=t.doc.lineAt(s),c=s==o.from?s-1:kn(o.text,s-o.from,!1)+o.from,u=s==o.to?s+1:kn(o.text,s-o.from,!0)+o.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),o=t.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=o.to,c.ranges.push(r)}else e.push({from:s.from,to:o.to,ranges:[r]});n=o.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let o of Gc(t)){if(n?o.to==t.doc.length:o.from==0)continue;let c=t.doc.lineAt(n?o.to+1:o.from-1),u=c.length+1;if(n){r.push({from:o.to,to:c.to},{from:o.from,insert:c.text+t.lineBreak});for(let f of o.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:o.from},{from:o.to,insert:t.lineBreak+c.text});for(let f of o.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let o of Gc(t))n?r.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):r.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Gc(e).map(({from:s,to:o})=>(s>0?s--:o{let o;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(o=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,o)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),o;return r&&s&&r.to<=e&&s.from>=e&&(o=r.type.prop(yt.closedBy))&&o.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:o,to:c}=s,u=e.doc.lineAt(o),f=!t&&o==c&&qO(e,o);t&&(o=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new Uc(e,{simulateBreak:o,simulateDoubleBreak:!!f}),g=Yx(h,o);for(g==null&&(g=nc(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));cu.from&&o{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let o=t.changes(s);return{changes:s,range:ke.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Uc(t,{overrideIndentation:o=>{let c=n[o];return c??-1}}),s=Gh(t,(o,c,u)=>{let f=Yx(r,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let h=/^\s*/.exec(o.text)[0],g=zc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(qh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Gh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let o=nc(s,t.tabSize),c=0,u=zc(t,Math.max(0,o-Hc(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Kh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Yh}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Yh,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Yh,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Kh,shift:Kh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:aO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:o}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),o!==void 0&&(c["aria-expanded"]=String(o)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const zo=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:o=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,ae=J)=>{const he=O.current;if(!he)return;const we=he.state.doc.length,T=Math.max(0,Math.min(J,we)),z=Math.max(0,Math.min(ae,we));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const ae=O.current;if(!ae)return null;const he=Math.max(0,Math.min(J,ae.state.doc.length)),we=ae.coordsAtPos(he);return we?{left:we.left,right:we.right,top:we.top,bottom:we.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,ae=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Qa.highest(Xe.domEventHandlers({keydown:we=>(_.current?.(we),we.defaultPrevented)})),Xe.updateListener.of(we=>{we.docChanged&&!L.current&&j.current(we.state.doc.toString()),(we.selectionSet||we.docChanged)&&R.current?.(we.state.selection.main.head)})]}),he=new Xe({state:ae,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const ae=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(ae.anchor,e.length),head:Math.min(ae.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(o,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});zo.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Xh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(o,c)=>n(e.map((u,f)=>f===o?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((o,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:o.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:o.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:o.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||po(t),s=n==="dark",o=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Xh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${o}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(zo,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:o,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Xh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${o}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${o}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${o}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Xh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${o}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(zo,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(zo,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const o=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,o]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>o(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>o("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} -});`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;a{const u=a.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` +`).map(o=>{const u=o.replace(/[ \t]+$/g,"").trimStart();if(!u)return"";const f=u.match(/^}+/)?.[0].length||0,h=Math.max(0,n-f),g=ZO(u,r);return r=g.state,n=Math.max(0,n+g.opens-g.closes),`${" ".repeat(h)}${u}`}).join(` `)}function Pv(t,e){return t.slice(0,Math.max(0,Math.min(e,t.length))).replace(/\r\n?/g,` `).length}function Yv(t,e,n){const r=t.split(` `),s=e.split(` -`),a=t.slice(0,Math.max(0,Math.min(n,t.length))),c=a.split(` -`).length-1,u=a.lastIndexOf(` -`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),o=t.slice(0,Math.max(0,Math.min(n,t.length))),c=o.split(` +`).length-1,u=o.lastIndexOf(` +`),f=o.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),o=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(o,s.length),selectionEnd:Math.min(Math.max(o,c),s.length)}}const Jh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Jh,"flex.collection":Jh,"flex.variables":Jh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,o)=>s.localeCompare(o)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,o]of r){const c=n.match(s);if(c)return{path:o,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function o3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function a3(t,e,n,r={},s=!1){const o=Math.max(0,Math.min(e,t.length)),c=t.slice(0,o),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:o-u.prefix.length,to:o,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:o-f.prefix.length,to:o,items:v}:null}const h=o3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:o-h.prefix.length,to:o,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:o-g.length,to:o,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:o={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,ae=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,ae))})},j=(B,K,ee=!1)=>{const be=a3(B,K,r,o,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(ao,{className:"h-3.5 w-3.5"}):p.jsx(Od,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(zo,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Xc="API-host execute route",Jc="the execute path";function Qc(t,e){return`${Xc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Qc("was unauthorized",`documentation authentication for ${Jc}`):t===403?Qc("was rejected",`CSRF, same-origin, and authorization middleware for ${Jc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Xc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Xc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Jc}.`:Qc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const o=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await o.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return o.status===429||o.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):o.redirected?Qc("was redirected",`authentication middleware for ${Jc}`):o.ok?`${Xc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(o.status,o.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Qh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Qh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Qh(n);if(!r)return t;const s=Qh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const o=new URL(t),c=`${o.pathname==="/"?"":o.pathname}${o.search}${o.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||po(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:o}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${o}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${o}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),o=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:o}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:o="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",ae=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",we=J||ae||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(ae),[qe,He]=I.useState(he),Je=I.useRef(we),$e=I.useRef(we),[ft,At]=I.useState(null),[bt,Ge]=I.useState(),[Q,re]=I.useState(null),[Se,Ne]=I.useState(null),[Be,We]=I.useState([]),[lt,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),ve=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Te=["GET","HEAD"].includes(Ae),je=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${je}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&o!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Fo=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=po(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Fo},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>o==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${le}-script-tab-${se}`,En=se=>`${le}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&o!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),ve.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Po=E?E(T.auth):T.auth,Qr=Pa({request:{...T,auth:Po},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),lu=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(ft,{...T,auth:Po},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ht(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Be.filter(se=>se.passed).length,Yo=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Yo&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${je}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||$e.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${je}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${je}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{ve.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Te&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:je,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:je,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(xf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:o==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>lu(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),o==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${je}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),o==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${je}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(bf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Yo,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(co,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),Se&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Cd,{className:"mt-0.5 h-4 w-4 shrink-0"}),Se]}),ft&&p.jsx(QO,{response:ft,theme:s,curlCommand:bt,advanced:o==="advanced"}),Be.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Be.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Be.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),lt.length>0&&p.jsx(Rr,{code:lt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Wh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:o,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(o,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(o||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>hf(K),[K]),ae=t1(D,_)!==t1(w.request,A),he=C==="advanced",we=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Wh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(bf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${we}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&ae&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(La,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${we}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Wh("tab",ne)},onScriptTabChange:ne=>{B(ne),Wh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>pf(Ce,ne))})]})};function Wc(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(t){if(!t)return"";try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"?e.origin:""}catch{return""}}function T3(t,e,n,r){const s=e.startsWith("/")?e:`/${e}`;return{method:t.toUpperCase(),url:n?`${n}${s}`:s,auth:{type:"none"},...r?{hostExecution:{preferHostExecution:!0}}:{}}}function j3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function E3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const O3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:o,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=j3(),h=o??nf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L){if(!(c?.runtimeOnly?.some(lt=>lt.path===e&<.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(lt=>lt.code==="runtime.operation-undocumented"&<.location.path===e&<.location.method?.toUpperCase()===n.toUpperCase())))return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const Se=N3(c?.serverOrigin),Ne=s.tryIt?.hostExecution,Be=Ne?.available===!0&&Ne.preferHostExecution!==!1,We=()=>u?.({request:T3(n,e,Se,Be),serverUrl:Se||void 0,scripts:{preRequest:"",tests:""},requestTab:"params",scriptTab:"pre-request"});return p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsxs("dl",{className:`mt-4 space-y-3 text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:[p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.contractEvidence||"Contract"}),p.jsx("dd",{children:ce?.contractNotDeclared||"OpenAPI does not declare this operation."})]}),p.jsxs("div",{children:[p.jsx("dt",{className:"font-semibold",children:ce?.runtimeEvidence||"Runtime"}),p.jsx("dd",{children:ce?.runtimeRouteUndocumented||`${n.toUpperCase()} ${e} is registered by the running service.`})]})]}),u&&p.jsxs("button",{type:"button",className:"mt-4 inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:We,children:[p.jsx(La,{className:"h-4 w-4"}),ce?.openApiClient||"Open in API Client"]})]})}if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",ae=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,we={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const Se=!A.has(re);w(Ne=>{const Be=new Set(Ne.key===b?Ne.sections:g);return Be.has(re)?Be.delete(re):Be.add(re),{key:b,sections:Be}}),re==="tryIt"&&E3("tryIt",Se?"1":void 0)},He=(re,Se,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Se}-heading`,children:[p.jsxs("button",{type:"button",id:`${Se}-heading`,"aria-expanded":A.has(Se),onClick:()=>qe(Se),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Se)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(Se)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},$e=(re,Se)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=ae.indexOf(Se),Be=re.key==="Home"?ae[0]:re.key==="End"?ae[ae.length-1]:re.key==="ArrowRight"?ae[(Ne+1)%ae.length]:ae[(Ne-1+ae.length)%ae.length];Je(Be)},ft=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wc(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,bt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{ft()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Cd,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&bt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:bt.map(([re,Se])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof Se=="string"?Se:JSON.stringify(Se)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...we})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,Se])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),Se.schema&&p.jsx(Dr,{spec:t,schema:Se.schema,theme:r,...we}),Se.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Se.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,Se])=>{const Ne=In.isReference(Se)?In.resolveReference(t,Se.$ref):Se;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([Be,We])=>{const lt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:Be}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...we})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),lt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(lt.value??lt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Be)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:ae.map(re=>p.jsx("button",{ref:Se=>{R.current[re]=Se},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:Se=>$e(Se,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function M3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function R3(t,e){let n=M3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function D3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const o of In.getHttpMethods(s)){const c=s[o];n.push({path:r,method:o,operation:c,score:R3(c,o),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const _3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",o=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=D3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:o,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${o}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${o}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${o}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${o}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${o}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${o}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(La,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(La,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${o}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${o}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const L3=typeof n1>"u"?{commit:"unknown"}:n1,q3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=L3,o=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),o]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},B3=(t,e,n)=>t==="dark"?n:e,$3="Runtime intelligence returned an invalid snapshot.",I3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),H3=new Set(["error","warning","info"]),z3=new Set(["pass","warn","fail","partial"]);function sn(){throw new Error($3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&sn(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&sn(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];sn()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&sn(),n}function U3(t){return Ji(t)||sn(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||sn(),t.map(U3)}function V3(t){(!Ji(t)||!Ji(t.location))&&sn();const e=Un(t,"code"),n=Un(t,"severity");(!I3.has(e)||!H3.has(n)||t.location.kind!=="operation")&&sn();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const o=i1(t,"expected");o!==void 0&&(r.expected=o);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),t.disposition!==void 0&&(t.disposition!=="acknowledged"&&sn(),r.disposition="acknowledged"),r}function F3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&sn();const e=Un(t,"status");z3.has(e)||sn();const n=t.findings.map(V3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&sn();const o=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==o&&sn(),{status:e,complete:t.complete,findings:n,summary:r}}function P3(t){Ji(t)||sn(),(!Ji(t.runtime)||!Ji(t.summary))&&sn(),typeof t.discoveryComplete!="boolean"&&sn();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const o=Zh(t,"serverOrigin");if(o&&(r.serverOrigin=o),t.server!==void 0){Ji(t.server)||sn();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&sn(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||sn(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=F3(t.validation)),r}const Y3=60;function K3(t,e,n=Y3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function G3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const X3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:o,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:o},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,o,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=K3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=G3(C.current);if(!J.length)return;const ae=J[0],he=J[J.length-1],we=document.activeElement;q.shiftKey&&(we===ae||!C.current.contains(we))?(q.preventDefault(),he.focus()):!q.shiftKey&&(we===he||!C.current.contains(we))&&(q.preventDefault(),ae.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},J3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function Q3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:o,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=W3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(o)?o.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:Q3(o),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(o)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),J3[D]]},D))]}),o!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function eM(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const tM=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:o,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),o();return}if(j.key!=="Tab"||!f.current)return;const R=eM(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,o]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:o}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:o,children:p.jsx(Md,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(nM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),o())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),o()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(ao,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function nM({result:t,theme:e,messages:n,onSelect:r}){const o=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:o,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code}),u.disposition==="acknowledged"&&p.jsx("span",{children:n?.acknowledgedFinding||"acknowledged"})]}),p.jsx("div",{className:`mt-1 text-xs ${o}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${o}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${o}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:o,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>o?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>o(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function iM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Zc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function eu(t){return Array.isArray(t)?`[${t.map(eu).join(",")}]`:Zc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${eu(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function rM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function o1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){o1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function sM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function a1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let o=n?s.get(n):void 0;for(;o&&!r.has(o.id);)r.add(o.id),o=o.parentFolderId?s.get(o.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const o of t.folders)o.collectionId!==e||!o.parentFolderId||r.has(o.id)||r.has(o.parentFolderId)&&(r.add(o.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const o=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))o.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&o.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function lM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[sM(r)],activeEnvironmentId:r.id}}function oM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=a1(r,e),o=f1(r,e);h1(o,e);const c=lM(r,n.environmentId),u={version:6,collections:[rM(s)],folders:d1(r,e),requests:o,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function aM(t){if(!Zc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function tu(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function cM(t,e){const n=a1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(o=>o.id===e.folderId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(o=>o.id===e.requestId&&o.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function uM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function dM(t){if(!Zc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Zc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=aM(t.scope),n=uM(t.workspace),r=oy(n);if(eu(n)!==eu(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");tu(r.collections,"collection"),tu(r.folders,"folder"),tu(r.requests,"request"),tu(r.environments,"environment"),cM(r,e);for(const s of r.requests)o1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function fM(t){return`${JSON.stringify(dM(t),null,2)} +`}function hM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let o=!0;for(;o;){o=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),o=!0)}return s}function Sl(t,e,n){const r=hM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function pM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(o=>o.id===e)?.name||"Deleted collection";if(!n)return r;const s=pM(t.folders.filter(o=>o.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function mM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function gM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const o=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=pf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&mM(E);let j;E.result&&!D&&(s=ay(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(o.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=o.filter(g=>g.cancelled).length,h=o.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:o.length,passed:u,failed:h,cancelled:f,stopped:c,items:o,workspace:s}}function Gr(){return new Date().toISOString()}function yM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const bM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:o,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,Se=(Ne,Be)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:Be}),Se(We.id,Be+1))})};return Se(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),Se(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],Se=new Set;let Ne=K.get(Q);for(;Ne&&!Se.has(Ne.id);)Se.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const Se=oM(h,Q),Ne=new Blob([fM(Se)],{type:"application/json;charset=utf-8"}),Be=URL.createObjectURL(Ne),We=document.createElement("a");We.href=Be,We.download=yM(re),We.click(),setTimeout(()=>URL.revokeObjectURL(Be),0),L("")}catch(Se){L(Se instanceof Error?Se.message:String(Se))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),Se=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:Se,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(Se),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(Se=>({...Se,folders:Se.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},ae=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(Se=>Se.id===M.id?{...Se,variables:[...Se.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:Se)}))},he=(Q,re)=>{if(!M)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Be=>Be.id===M.id?{...Be,variables:Be.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:Se}:Be)}))},we=Q=>{if(!M)return;const re=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter(Be=>Be.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),Se=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:Se,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(Se),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map(Be=>Be.id===j?{...Be,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:Be)}));return}const Se={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,Se]})),R(Se.id),O(Q)},me=Q=>{const re=h.requests.find(Se=>Se.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(Se=>Se.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(Se=>Se.id===Q);g(Se=>LC(Se,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",$e=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),ft=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=be(Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return p.jsxs(kd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Be}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${Be} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},Be),children:p.jsx(Td,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Be}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(lt=>ft(lt,re+1,Ne))]},Q.id)},At=(Q,re,Se=new Set)=>{if(Se.has(Q.id))return null;const Ne=new Set(Se);Ne.add(Q.id);const Be=Y.filter(lt=>lt.folderId===Q.id),We=G.filter(lt=>lt.parentFolderId===Q.id);return Be.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Be.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:Be.map($e)})]}),We.map(lt=>At(lt,re+1,Ne))]},Q.id)},bt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>o?.(Q.id),children:p.jsx(co,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Td,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(xf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:ae,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:Se=>he(Q.id,{enabled:Se.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:Se=>he(Q.id,{key:Se.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:Se=>he(Q.id,{value:Se.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>we(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),bt.map(Q=>ft(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(xf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map($e),bt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function Uo(){return new Date().toISOString()}const xM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),o=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=Uo(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!o)return;const w=Uo();e(A=>({...A,environments:A.environments.map(C=>C.id===o.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!o)return;const C=Uo();e(E=>({...E,environments:E.environments.map(D=>D.id===o.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!o)return;const A=Uo();e(C=>({...C,environments:C.environments.map(E=>E.id===o.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),o&&p.jsx("button",{type:"button","aria-label":`Delete environment ${o.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,o.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),o&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:o.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[o.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),o.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function nu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function vM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",o=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,o,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=nu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function wM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),o=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:o,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const o=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=kd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` -`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${o}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:o,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${o}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":o,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":o}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${o}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${o}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function op(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function AM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=AM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,o)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${o}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const kM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:o,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:o||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>vM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>wM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},ae=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],we=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:ae,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=nu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[op(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:nu(ne)?"text-red-600":j,children:op(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:nu(B)?"text-red-600":j,children:op(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[we,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ot(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?ot(r.value):""}function CM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function ap(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=CM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const o=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return o("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){o("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return o("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){o("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(o("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const o=ot(r.key).trim();return o?[{id:An("variable"),key:o,value:ot(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function NM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(o=>t.includes(o));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function TM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(ot).join(` +`):ot(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,o)=>{const c=ot(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${o}]`,f=TM(s.script,`${u}.script`,n).trim();if(!f)return;const h=NM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function jM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function EM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(o=>{const c=o.indexOf("=");return{key:S1(c>=0?o.slice(0,c):o),value:S1(c>=0?o.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function OM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function MM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=ot(r.key).trim();s&&(n=n.replace(new RegExp(`:${MM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function RM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=OM(t.query),n=ot(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=ot(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(ot).join("."):ot(t.host),o=ot(t.port),c=Array.isArray(t.path)?t.path.map(ot).join("/"):ot(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${o?`:${o}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function DM(t){return Xr(t).map(e=>({key:ot(e.key),value:ot(e.value),enabled:e.disabled!==!0}))}function _M(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function LM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function qM(t,e,n,r){const s=_M(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const o=ot(t.mode);if(o==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?ot(c.language):"";return{body:ot(t.raw),contentType:s||LM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(o==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:ot(u.key),value:ot(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(o==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=ot(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:ot(c.query),variables:u},contentType:s||"application/json"}}if(o==="formdata"){const c=Xr(t.formdata).map(f=>{const h=ot(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(ot).filter(Boolean).join(", "):ot(f.src);return{key:ot(f.key),value:h==="text"?ot(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(o==="file"){const c=mn(t.file)?ot(t.file.src):ot(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${o}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function BM(t,e,n,r,s,o,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=ot(f.method).trim().toUpperCase()||"GET",g=RM(f.url),b=DM(f.header),v=qM(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:ap(f.auth,{type:"inherit"},`${c}.auth`,u)},A=EM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:o,updatedAt:o}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=ot(e.name)||"Untitled",o=w1(e.event,`${r}.event`,t.warnings),c=jM(t.inheritedScripts,o);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:ap(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=BM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function $M(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=ot(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=ot(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),o=An("collection"),c={id:o,name:e,auth:ap(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:o,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function IM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=ot(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function HM(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:$M(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:IM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function zM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function UM(t,e){const n=zM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function VM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const FM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,o]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=HM(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?UM(M,G.result):VM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?o({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?o({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):o({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(ao,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Od,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function PM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let o=n.get(e.folderId);for(;o&&!s.has(o.id);)s.add(o.id),r.unshift(o.name),o=o.parentFolderId?n.get(o.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function YM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const KM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const ae=await gM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:o,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(we=>({...we,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(we=>({...we,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(ae.workspace),Y(he=>Object.fromEntries(C.map(we=>{const T=he[we.id]||{status:"pending"};return[we.id,T.status==="pending"&&ae.stopped?{status:"skipped"}:T]}))),M(ae),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_a,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(co,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(co,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,ae)=>{const he=G[J.id]||{status:"pending"},we=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=we?.status!==void 0&&we.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:ae+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:PM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(ao,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:YM(he)}),we?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",we.status]}),we?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(Nd,{className:"mr-1 inline h-3.5 w-3.5"}),we.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Vo(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function GM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return po(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function XM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:o="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=GM(t),Y=Sn(e),B=nl(),K=o===!1?{}:j1(o),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[ae,he]=I.useState(Y),[we,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[$e,ft]=I.useState({}),[At,bt]=I.useState(),[Ge,Q]=I.useState(B),[re,Se]=I.useState(B.collections[0]?.id),[Ne,Be]=I.useState(""),We=I.useRef(B.collections[0]?.id),lt=I.useRef(void 0),[ti,Tn]=I.useState(o===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(o===!1)return;let Me=!1;return hy(o).then(Ze=>{Me||(Q(Ze),Se(Ze.collections[0]?.id),Be(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[o]);const x=my(o,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>hf(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,ae),[ce,ae]),V=I.useMemo(()=>XM(ce,ae)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,ae,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),ve=I.useCallback(Me=>{Se(Me),Be("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},le=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),o!==!1&&Vo(o,{requestTab:Me}),C?.(Me)},Te=Me=>{qe(Me),o!==!1&&Vo(o,{scriptTab:Me}),E?.(Me)},je=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>pf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,lt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>ay(Ze,{...Me,collectionId:We.current,folderId:lt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Se(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Be(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),o!==!1&&Vo(o,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{Se(Me),Be(Ze||""),bt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{ft({entryId:Me,runId:Ze}),Je("history")},Fo=()=>ni(Me=>{const Ze=!Me;return o!==!1&&Vo(o,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Fo,children:ht?p.jsx(Ed,{className:"h-4 w-4"}):p.jsx(jd,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(bf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(FM,{onWorkspaceChange:Q,onSelectedCollectionChange:ve,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(xM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(bM,{request:ce,scripts:ae,onLoadRequest:Dt,onSelectedCollectionChange:ve,onSelectedFolderChange:Be,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),o!==!1&&Vo(o,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(kM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:$e.entryId,initialRunId:$e.runId,theme:kt},`${$e.runId||""}:${$e.entryId||""}`):He==="runner"&&At?p.jsx(KM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:we,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:je,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:le,onRequestTabChange:Ae,onScriptTabChange:Te,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function iu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function JM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,o]of Object.entries(t.paths))for(const c of In.getHttpMethods(o)){if(Wc(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function QM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${iu(n.padding.vertical)||"0"} ${iu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:iu(n.maxHeight)||"32px",maxWidth:iu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const WM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const o=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=ho(o),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:o,preferences:c})),ae=I.useRef(null),he=I.useRef(null),we=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===o?q.preferences:ho(o),Je=n&&He.theme||e,$e=Je==="high-contrast"?"dark":Je,ft=He.expand,At=He.expandedTags??["default"],bt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...JM($e,Ge),...r}),[$e,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return P3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>{const le=R1(t,window.location.hash);if(le){g(le);return}const Ae=window.location.hash.replace(/^#/,"");g(Te=>Te&&Ae&&Wc(Te.path,Te.method)===Ae?Te:null)},de=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const le=ae.current,Ae=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Te=je=>{if(je.key==="Escape"){je.preventDefault(),M(!1);return}if(je.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];je.shiftKey&&document.activeElement===ze?(je.preventDefault(),Ve.focus()):!je.shiftKey&&document.activeElement===Ve&&(je.preventDefault(),ze.focus())};return document.addEventListener("keydown",Te),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Te),de?.focus()}},[L]);const re=()=>{J({key:o,preferences:ho(o)})},Se=F=>{J(de=>{const le=de.key===o?de.preferences:ho(o);return{key:o,preferences:{...le,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>we.current?.scrollTo({top:0,behavior:"auto"})),Be=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wc(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},lt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!bt;Ba(o,"sidebarCollapsed",F),Se({sidebarCollapsed:F})},ht=nf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ft===void 0?ht:nf(ft),Vn=F=>{Ba(o,"expand",F),re()},qn=F=>{n&&(Ba(o,"theme",F),re())},kt=F=>{Ba(o,"expandedTags",F),Se({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=B3($e,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=$e==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=$e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),ve=p.jsx(pk,{spec:t,onEndpointSelect:Be,theme:$e,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.logo?p.jsx(QM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(iM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":bt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!bt,onClick:Tn,children:bt?p.jsx(Ed,{className:"h-5 w-5"}):p.jsx(jd,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_a,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${$e==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${bt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":bt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!bt&&ve}),p.jsxs("main",{ref:we,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(O3,{spec:t,path:h.path,method:h.method,theme:$e,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:lt}):p.jsx(_3,{spec:t,onEndpointSelect:Be,theme:$e}),p.jsx(q3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:$e,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:ae,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${$e==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Md,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:ve})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${$e==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(tM,{open:B&&T,theme:$e,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:Be,messages:X}),p.jsx(X3,{spec:t,theme:$e,messages:X,onEndpointSelect:Be,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>lt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Z3,{open:G,theme:$e,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:ft,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function ZM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function eR(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function tR(t,e){const n=e.load||ZM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),o={},c=new Map;async function u(g){if(g===r)return s;if(o[g])return o[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return o[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=eR(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(o).length&&(s[dp]=o),s}async function nR(t,e){return tR(t,e)}const ru="1",su=new WeakMap;function iR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=iR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},o=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!o.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function rR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function sR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=su.get(t);n&&n.unmount();const r=$A.createRoot(t);return su.set(t,r),r.render(e),()=>{su.get(t)===r&&su.delete(t),r.unmount()}}function $1(t,e,n){return sR(n),B1(t,p.jsx(WM,{spec:fp(e,n),theme:rR(n),options:n}))}function I1(t,e){const n={contractVersion:ru,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:ru,...e.options||{}},r=e.baseUri?await nR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:ru}),As.FLEXDOC_CONTRACT_VERSION=ru,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/docs/runtime-intelligence.md b/docs/runtime-intelligence.md index 11d5bc7c..5d7a250c 100644 --- a/docs/runtime-intelligence.md +++ b/docs/runtime-intelligence.md @@ -148,7 +148,7 @@ The Node Runtime Intelligence snapshot can include one backend-produced `validat The four finding codes in this cut are: -- `runtime.operation-undocumented` — the running backend positively exposes an operation that OpenAPI does not document. Severity: `error` when discovery is complete, `warning` when discovery is partial, matching the other findings that must not treat an incomplete inventory as authoritative. The finding names the method and path and opens that registered route. It is not an OpenAPI operation. When discovery is complete the derived status is `fail`, and `flexdoc validate` exits `1` under the default policy. Set `runtimeIntelligence.acknowledgedUndocumented` to method/path pairs that are intentionally absent from OpenAPI; those operations are omitted from this finding. +- `runtime.operation-undocumented` — the running backend positively exposes an operation that OpenAPI does not document. Severity: `error` when discovery is complete, `warning` when discovery is partial, matching the other findings that must not treat an incomplete inventory as authoritative. The finding names the method and path and opens that registered route. It is not an OpenAPI operation. The page shows the contract claim — OpenAPI does not declare the operation — beside the registered method and path. It does not invent a handler or a schema. **Open in API Client** sends that method and path on `serverOrigin` when the snapshot has one, and as a same-origin path otherwise. It does not use the OpenAPI server URL. The request asks to prefer the API host only when host execution is available and the server has not set `preferHostExecution` to false. `runtimeIntelligence.acknowledgedUndocumented` keeps the route registered and records the finding as acknowledged info, so that finding does not fail validation. An unacknowledged route still fails when discovery is complete, and `flexdoc validate` exits `1`. - `runtime.operation-unobserved` — OpenAPI documents an operation that runtime discovery did not observe. Severity: `error` when discovery is complete, `info` when discovery is partial. - `runtime.method-mismatch` — the same wire-equivalent path exists in both sources but under different HTTP methods. Severity: `error` when discovery is complete, `warning` when partial. The finding carries an expected documented method so the renderer can navigate to the spec operation. - `runtime.duplicate-operation` — the host exposes multiple registrations for one wire-equivalent method/path. Severity: `warning`. In 3.1 this is an explicitly supported/verified claim for Express (including Nest-on-Express) and Hono. Fastify participates in the other validation checks, but exact duplicate-registration reporting is not claimed for Fastify in this cut. diff --git a/e2e/runtime-intelligence.spec.cjs b/e2e/runtime-intelligence.spec.cjs index 144e6f09..b3e69a3a 100644 --- a/e2e/runtime-intelligence.spec.cjs +++ b/e2e/runtime-intelligence.spec.cjs @@ -82,3 +82,43 @@ test('runtime drift rows navigate to documented operations', async ({ page }, te await expect(page.getByRole('heading', { name: 'Get a pet' })).toBeVisible(); await expect(page).toHaveURL(/#get-~2Fpets~2F~7Bid~7D$/); }); + +test('an undocumented runtime finding opens, shows the contract gap, and hands off to the API Client', async ({ page }, testInfo) => { + test.skip(testInfo.project.name !== 'chromium-desktop', 'desktop runtime disagreement loop'); + const disagreement = { + ...runtimeSnapshot, + discoveryComplete: true, + serverOrigin: 'https://staging.internal', + routes: [{ method: 'POST', path: '/internal/reindex' }], + runtimeOnly: [{ method: 'POST', path: '/internal/reindex' }], + documentedOnly: [], + summary: { documented: 1, runtime: 1, matched: 0, runtimeOnly: 1, documentedOnly: 0 }, + validation: { + status: 'fail', + complete: true, + findings: [{ + id: 'runtime.operation-undocumented:POST:/internal/reindex', + code: 'runtime.operation-undocumented', + severity: 'error', + location: { kind: 'operation', method: 'POST', path: '/internal/reindex' }, + message: 'Runtime implements POST /internal/reindex, but OpenAPI does not document that operation.', + expected: 'Operation is represented in OpenAPI', + observed: 'Operation exists only in the running backend', + }], + summary: { total: 1, errors: 1, warnings: 0, info: 0 }, + }, + }; + await page.route('**/e2e/__flexdoc/runtime', async (route) => { + await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(disagreement) }); + }); + await page.goto('/e2e/index.html?runtime=1'); + await page.getByRole('button', { name: 'Open runtime intelligence' }).click(); + const dialog = page.getByRole('dialog', { name: 'Runtime intelligence' }); + await dialog.getByRole('button', { name: 'Open runtime route POST /internal/reindex' }).click(); + await expect(dialog).toBeHidden(); + await expect(page.getByText('OpenAPI does not declare this operation.')).toBeVisible(); + await expect(page.getByText('POST /internal/reindex is registered by the running service.')).toBeVisible(); + await page.getByRole('button', { name: 'Open in API Client' }).click(); + await expect(page.getByLabel('Request URL')).toHaveValue('https://staging.internal/internal/reindex'); + await expect(page.getByLabel('HTTP method')).toHaveValue('POST'); +}); diff --git a/examples/javascript-express/README.md b/examples/javascript-express/README.md index 8e51b73c..3bc9c250 100644 --- a/examples/javascript-express/README.md +++ b/examples/javascript-express/README.md @@ -2,7 +2,7 @@ This is the primary backend-native FlexDoc 3.1 showcase. Express serves the shared OpenAPI 3.1 contract, while FlexDoc runs inside the same backend and exposes the completed documentation/API Client surface plus live Runtime Intelligence. -The example registers `GET /internal/health` without documenting it, and lists that operation in `runtimeIntelligence.acknowledgedUndocumented`. Contract validation stays green. The route stays on the snapshot's `routes` array. The Runtime panel shows findings rather than that array, so an acknowledged route does not appear there. +`GET /internal/health` is registered and listed in `runtimeIntelligence.acknowledgedUndocumented`. It stays a runtime-only route, the finding is informational, and it does not fail validation. `POST /internal/reindex` is also registered and is not acknowledged, so contract validation fails. Open **Runtime**, then that finding, to see the registered route beside the missing contract and send it from the API Client. The renderer also demonstrates the completed documentation/API Client surface: persisted viewer preferences, deep links, keyboard command palette, mobile navigation, JSON/YAML download, Basic/Advanced Try It, handoff to the sibling API Client page, environments, scripts, the CodeMirror-backed editor, response inspection, collection/history workflows, and code samples. diff --git a/examples/javascript-express/index.js b/examples/javascript-express/index.js index 828056dd..4f6e4482 100644 --- a/examples/javascript-express/index.js +++ b/examples/javascript-express/index.js @@ -57,6 +57,7 @@ function buildApp() { // Intentionally omitted from the OpenAPI document so Runtime Intelligence has real drift to report. app.get('/internal/health', (_req, res) => res.json({ status: 'internal-ok' })); + app.post('/internal/reindex', (_req, res) => res.json({ accepted: true })); // Security ordering matters for host execution: // 1. authenticate the whole documentation subtree; @@ -106,7 +107,7 @@ function buildApp() { } if (require.main === module) { - buildApp().listen(3000, () => console.log('Login: http://localhost:3000/example-login\nAPI: http://localhost:3000/pets\nDocs: http://localhost:3000/docs\nGET /internal/health is acknowledged as intentionally undocumented')); + buildApp().listen(3000, () => console.log('Login: http://localhost:3000/example-login\nAPI: http://localhost:3000/pets\nDocs: http://localhost:3000/docs\nGET /internal/health is acknowledged. POST /internal/reindex is undocumented and fails validation.')); } module.exports = { buildApp }; diff --git a/examples/javascript-fastify/README.md b/examples/javascript-fastify/README.md index b137bcb7..000f11ff 100644 --- a/examples/javascript-fastify/README.md +++ b/examples/javascript-fastify/README.md @@ -2,7 +2,7 @@ This example serves the shared OpenAPI 3.1 showcase through Fastify and enables FlexDoc 3.1 Runtime Intelligence. FlexDoc reads Fastify's registered route tree at runtime, normalizes framework route syntax, and compares it with the exact OpenAPI document passed to the integration. -`GET /internal/health` is absent from the spec and listed in `runtimeIntelligence.acknowledgedUndocumented`, so contract validation stays green. The route stays on the snapshot's `routes` array. The Runtime panel shows findings rather than that array, so the acknowledged route does not appear there. The renderer still exposes Basic/Advanced Try It, handoff to the sibling API Client page, persisted workspace state, scripts, response inspection, keyboard workflows and code samples. +`GET /internal/health` is absent from the spec and listed in `runtimeIntelligence.acknowledgedUndocumented`, so that finding is informational. `POST /internal/reindex` is also absent from the spec and is not acknowledged, so contract validation fails. The renderer still exposes Basic/Advanced Try It, handoff to the sibling API Client page, persisted workspace state, scripts, response inspection, keyboard workflows and code samples. ```bash npm install diff --git a/examples/javascript-fastify/index.js b/examples/javascript-fastify/index.js index bd02c9dd..05a42dd5 100644 --- a/examples/javascript-fastify/index.js +++ b/examples/javascript-fastify/index.js @@ -17,6 +17,7 @@ async function buildApp() { app.patch('/pets/:petId', async (request) => ({ id: request.params.petId, name: 'Miso', age: 3, tags: ['friendly'], status: 'available', ...(request.body || {}) })); app.get('/search', async (request) => ({ terms: request.query.terms || [], count: 1 })); app.get('/internal/health', async () => ({ status: 'internal-ok' })); + app.post('/internal/reindex', async () => ({ accepted: true })); setupFastifyFlexDoc(app, '/docs', { spec, @@ -48,7 +49,7 @@ async function main() { await app.listen({ port: 3000, host: '0.0.0.0' }); console.log('API: http://localhost:3000/pets'); console.log('Docs: http://localhost:3000/docs'); - console.log('GET /internal/health is acknowledged as intentionally undocumented'); + console.log('GET /internal/health is acknowledged. POST /internal/reindex is undocumented and fails validation.'); } if (require.main === module) { diff --git a/examples/javascript-hono/README.md b/examples/javascript-hono/README.md index e4a19f1e..4cbdabb2 100644 --- a/examples/javascript-hono/README.md +++ b/examples/javascript-hono/README.md @@ -2,6 +2,6 @@ This example uses Hono `4.13.x` with the optional `setupHonoFlexDoc` integration. Its registry dependency is pinned to published `@prauga/flexdoc-backend` `3.3.0` for reproducible standalone installs, while repository CI validates against the backend package built from the current commit. Runtime Intelligence reads Hono's actual registered routes instead of inferring them from the OpenAPI document. -The contract documents `/health` and `/pets/{petId}`. `GET /internal/health` is registered only in Hono and listed in `runtimeIntelligence.acknowledgedUndocumented`, so validation stays green. The route stays on the snapshot's `routes` array. The Runtime panel shows findings rather than that array, so the acknowledged route does not appear there. The docs surface also enables Basic/Advanced Try It, handoff to the sibling API Client page, persisted workspace state and code samples. +The contract documents `/health` and `/pets/{petId}`. `GET /internal/health` is listed in `runtimeIntelligence.acknowledgedUndocumented`, so that finding is informational. `POST /internal/reindex` is registered only in Hono and is not acknowledged, so contract validation fails. The docs surface also enables Basic/Advanced Try It, handoff to the sibling API Client page, persisted workspace state and code samples. The integration remains framework-native without making Hono a hard dependency of the core backend package. diff --git a/examples/javascript-hono/index.mjs b/examples/javascript-hono/index.mjs index 5acad5a4..3775cf52 100644 --- a/examples/javascript-hono/index.mjs +++ b/examples/javascript-hono/index.mjs @@ -37,8 +37,9 @@ export const app = new Hono(); app.get('/health', (c) => c.json({ status: 'ok' })); app.get('/pets/:petId', (c) => c.json({ id: c.req.param('petId'), name: 'Miso' })); -// Absent from the contract and acknowledged so validation stays green. +// Acknowledged, so the finding is informational. /internal/reindex is the drift that fails validation. app.get('/internal/health', (c) => c.json({ status: 'internal-ok' })); +app.post('/internal/reindex', (c) => c.json({ accepted: true })); setupHonoFlexDoc(app, '/docs', { spec, diff --git a/packages/backend/src/contract-validation.test.ts b/packages/backend/src/contract-validation.test.ts index ef57d5d3..34a473f5 100644 --- a/packages/backend/src/contract-validation.test.ts +++ b/packages/backend/src/contract-validation.test.ts @@ -89,7 +89,7 @@ describe('runtime contract validation', () => { })); }); - it('omits runtime operations the operator has acknowledged as undocumented', () => { + it('keeps an acknowledged undocumented route as info and does not fail validation', () => { const result = validateRuntimeContract({ documentedRoutes: [{ method: 'GET', path: '/pets' }], runtimeRoutes: [ @@ -100,7 +100,13 @@ describe('runtime contract validation', () => { discoveryComplete: true, }); expect(result.status).toBe('pass'); - expect(result.findings).toEqual([]); + expect(result.summary).toEqual({ total: 1, errors: 0, warnings: 0, info: 1 }); + expect(result.findings[0]).toEqual(expect.objectContaining({ + code: 'runtime.operation-undocumented', + severity: 'info', + disposition: 'acknowledged', + location: { kind: 'operation', method: 'GET', path: '/internal/health' }, + })); }); it('reports duplicate host registrations that standalone OpenAPI tooling cannot observe', () => { diff --git a/packages/backend/src/contract-validation.ts b/packages/backend/src/contract-validation.ts index 5afb346b..d2aa4423 100644 --- a/packages/backend/src/contract-validation.ts +++ b/packages/backend/src/contract-validation.ts @@ -36,6 +36,7 @@ export interface FlexDocContractValidationFinding { /** Human-readable explanation suitable for UI and CI output. */ message: string; /** Concise expected contract/runtime state. */ expected?: string | string[]; /** Concise state actually observed from the running backend. */ observed?: string | string[]; + /** Operator policy applied to this finding. Absence means the finding is still actionable. */ disposition?: 'acknowledged'; } /** Aggregate finding counts for one contract-validation pass. */ @@ -63,7 +64,7 @@ export interface ValidateRuntimeContractOptions { /** Normalized operations discovered from the running backend. */ runtimeRoutes: FlexDocContractRoute[]; /** Runtime operations that were registered more than once by the host framework. */ duplicateRuntimeRoutes?: FlexDocContractDuplicateRuntimeRoute[]; /** Whether route discovery is believed to cover the complete running application. */ discoveryComplete: boolean; - /** Runtime operations intentionally absent from OpenAPI. They are not reported as undocumented. */ acknowledgedUndocumented?: FlexDocContractRoute[]; + /** Runtime operations the operator has accepted as intentionally absent from OpenAPI. They remain registered and are reported as acknowledged info. */ acknowledgedUndocumented?: FlexDocContractRoute[]; } function routeShape(path: string): string { @@ -147,15 +148,17 @@ export function validateRuntimeContract(options: ValidateRuntimeContractOptions) for (const route of options.runtimeRoutes) { const shape = routeShape(route.path); if (methodMismatchShapes.has(shape)) continue; - if (documentedKeys.has(exactShapeKey(route)) || acknowledgedKeys.has(exactShapeKey(route))) continue; + if (documentedKeys.has(exactShapeKey(route))) continue; + const acknowledged = acknowledgedKeys.has(exactShapeKey(route)); findings.push({ id: findingId('runtime.operation-undocumented', route.path, route.method), code: 'runtime.operation-undocumented', - severity: options.discoveryComplete ? 'error' : 'warning', + severity: acknowledged ? 'info' : (options.discoveryComplete ? 'error' : 'warning'), + ...(acknowledged ? { disposition: 'acknowledged' as const } : {}), location: { kind: 'operation', method: route.method.toUpperCase(), path: route.path }, message: `Runtime implements ${route.method.toUpperCase()} ${route.path}, but OpenAPI does not document that operation.`, expected: 'Operation is represented in OpenAPI', - observed: 'Operation exists only in the running backend', + observed: acknowledged ? 'Operation exists only in the running backend and is acknowledged' : 'Operation exists only in the running backend', }); } diff --git a/packages/backend/src/runtime-intelligence.test.ts b/packages/backend/src/runtime-intelligence.test.ts index cc7e0cc0..d0a5ea0e 100644 --- a/packages/backend/src/runtime-intelligence.test.ts +++ b/packages/backend/src/runtime-intelligence.test.ts @@ -156,11 +156,13 @@ describe('runtime intelligence', () => { { method: 'GET', path: '/internal/health' }, { method: 'GET', path: '/pets' }, ]); - expect(snapshot.runtimeOnly).toEqual([]); - expect(snapshot.summary).toEqual({ documented: 1, runtime: 1, matched: 1, runtimeOnly: 0, documentedOnly: 0 }); - expect(snapshot.summary.matched + snapshot.summary.runtimeOnly).toBe(snapshot.summary.runtime); + expect(snapshot.runtimeOnly).toEqual([{ method: 'GET', path: '/internal/health' }]); + expect(snapshot.summary).toEqual({ documented: 1, runtime: 2, matched: 1, runtimeOnly: 1, documentedOnly: 0 }); expect(snapshot.validation.status).toBe('pass'); - expect(snapshot.validation.findings).toEqual([]); + expect(snapshot.validation.findings[0]).toEqual(expect.objectContaining({ + disposition: 'acknowledged', + severity: 'info', + })); }); it('feeds duplicate host registrations into contract validation', () => { diff --git a/packages/backend/src/runtime-intelligence.ts b/packages/backend/src/runtime-intelligence.ts index 5aaabc88..5cf37624 100644 --- a/packages/backend/src/runtime-intelligence.ts +++ b/packages/backend/src/runtime-intelligence.ts @@ -43,7 +43,7 @@ export interface FlexDocRuntimeDiscovery { /** Aggregate route counts in a Runtime Intelligence snapshot. */ export interface FlexDocRuntimeIntelligenceSummary { /** Number of documented OpenAPI operations. */ documented: number; - /** Runtime routes in the drift comparison. Equals `matched + runtimeOnly`. Acknowledged undocumented routes stay in `routes` and are excluded here. */ runtime: number; + /** Number of routes the framework registered, including acknowledged undocumented routes. */ runtime: number; /** Number of wire-equivalent method/path matches between runtime and OpenAPI. */ matched: number; /** Number of runtime-only routes. */ runtimeOnly: number; /** Number of documented-only routes. */ documentedOnly: number; @@ -351,9 +351,8 @@ export function buildRuntimeIntelligenceSnapshot(input: FlexDocRuntimeIntelligen const runtimeRoutes = uniqueSorted(input.discovery.routes); const documentedKeys = new Set(documented.map(contractRouteKey)); const runtimeKeys = new Set(runtimeRoutes.map(contractRouteKey)); - const acknowledgedKeys = new Set((input.acknowledgedUndocumented || []).map(contractRouteKey)); const matched = runtimeRoutes.filter((route) => documentedKeys.has(contractRouteKey(route))).length; - const runtimeOnly = runtimeRoutes.filter((route) => !documentedKeys.has(contractRouteKey(route)) && !acknowledgedKeys.has(contractRouteKey(route))); + const runtimeOnly = runtimeRoutes.filter((route) => !documentedKeys.has(contractRouteKey(route))); const documentedOnly = documented.filter((route) => !runtimeKeys.has(contractRouteKey(route))); const environment = input.environment || nodeEnvironmentMetadata(); const validation = validateRuntimeContract({ @@ -377,7 +376,7 @@ export function buildRuntimeIntelligenceSnapshot(input: FlexDocRuntimeIntelligen documentedOnly, summary: { documented: documented.length, - runtime: matched + runtimeOnly.length, + runtime: runtimeRoutes.length, matched, runtimeOnly: runtimeOnly.length, documentedOnly: documentedOnly.length, diff --git a/packages/client/src/components/EndpointDetail.runtime-route.test.tsx b/packages/client/src/components/EndpointDetail.runtime-route.test.tsx index cafed60e..b6248f2e 100644 --- a/packages/client/src/components/EndpointDetail.runtime-route.test.tsx +++ b/packages/client/src/components/EndpointDetail.runtime-route.test.tsx @@ -2,7 +2,7 @@ // stale useState value cannot be observed. This file uses real React. jest.unmock('react'); -import { render, screen } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import { EndpointDetail } from './EndpointDetail'; import type { OpenAPISpec } from '../types/openapi'; @@ -33,7 +33,63 @@ describe('EndpointDetail runtime-only routes', () => { render(); expect(screen.getByText('POST')).toBeInTheDocument(); expect(screen.getByText('/internal/reindex')).toBeInTheDocument(); - expect(screen.getByText('The running service registers this operation. OpenAPI does not document it.')).toBeInTheDocument(); + expect(screen.getByText('Contract')).toBeInTheDocument(); + expect(screen.getByText('OpenAPI does not declare this operation.')).toBeInTheDocument(); + expect(screen.getByText('Runtime')).toBeInTheDocument(); + expect(screen.getByText('POST /internal/reindex is registered by the running service.')).toBeInTheDocument(); + }); + + it('joins the runtime path only to the origin that registered it', () => { + const open = jest.fn(); + render(); + fireEvent.click(screen.getByRole('button', { name: 'Open in API Client' })); + expect(open.mock.calls[0][0].serverUrl).toBe('https://staging.internal'); + expect(open.mock.calls[0][0].request.url).toBe('https://staging.internal/internal/reindex'); + expect(open.mock.calls[0][0].request.hostExecution).toEqual({ preferHostExecution: true }); + }); + + it('stays same-origin when the snapshot has no server origin', () => { + const open = jest.fn(); + render(); + fireEvent.click(screen.getByRole('button', { name: 'Open in API Client' })); + expect(open.mock.calls[0][0].serverUrl).toBeUndefined(); + expect(open.mock.calls[0][0].request.url).toBe('/internal/reindex'); + }); + + it('does not ask for host execution when the server has opted out', () => { + const open = jest.fn(); + render(); + fireEvent.click(screen.getByRole('button', { name: 'Open in API Client' })); + expect(open.mock.calls[0][0].request.hostExecution).toBeUndefined(); + }); + + it('keeps a browser request when host execution is unavailable', () => { + const open = jest.fn(); + render(); + fireEvent.click(screen.getByRole('button', { name: 'Open in API Client' })); + expect(open.mock.calls[0][0].request.hostExecution).toBeUndefined(); + expect(open.mock.calls[0][0].request.url).toBe('/internal/reindex'); }); it('keeps an unknown path as operation not found', () => { @@ -43,7 +99,7 @@ describe('EndpointDetail runtime-only routes', () => { it('renders a documented operation after a runtime-only route in the same instance', () => { const { rerender } = render(); - expect(screen.getByText('The running service registers this operation. OpenAPI does not document it.')).toBeInTheDocument(); + expect(screen.getByText('POST /internal/reindex is registered by the running service.')).toBeInTheDocument(); rerender(); expect(screen.queryByText('Operation not found.')).not.toBeInTheDocument(); expect(screen.getByRole('heading', { name: 'List pets' })).toBeInTheDocument(); diff --git a/packages/client/src/components/EndpointDetail.tsx b/packages/client/src/components/EndpointDetail.tsx index a8ff1f6c..8c9cb71b 100644 --- a/packages/client/src/components/EndpointDetail.tsx +++ b/packages/client/src/components/EndpointDetail.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useId, useMemo, useRef, useState } from 'react'; -import { AlertCircle, Check, ChevronDown, ChevronRight, Link2, Lock, Unlock } from 'lucide-react'; +import { AlertCircle, Check, ChevronDown, ChevronRight, ExternalLink, Link2, Lock, Unlock } from 'lucide-react'; import { OpenAPISpec, Operation, RequestBody, Response } from '../types/openapi'; import { ExpandSection, FlexDocRendererOptions, FlexDocRuntimeIntelligenceSnapshot } from '../types/options'; import { resolveExpandSections } from '../utils/renderer-preferences'; @@ -12,6 +12,7 @@ import { SchemaView } from './SchemaView'; import { TryItApiClientWorkspace } from './TryItApiClientWorkspace'; import type { TryItApiClientHandoff } from './TryItApiClientWorkspace'; import { operationHashId } from '../utils/operation-id'; +import type { HttpRequestDraft } from '../utils/http-client'; interface EndpointDetailProps { spec: OpenAPISpec; @@ -32,6 +33,26 @@ interface ViewerDeepLinkState { const DEFAULT_LANGUAGES: CodeSampleLanguage[] = ['curl', 'javascript', 'python', 'go', 'java']; +function httpOrigin(value: string | undefined): string { + if (!value) return ''; + try { + const url = new URL(value); + return url.protocol === 'http:' || url.protocol === 'https:' ? url.origin : ''; + } catch { + return ''; + } +} + +function runtimeRouteRequest(method: string, path: string, origin: string, preferHost: boolean): HttpRequestDraft { + const suffix = path.startsWith('/') ? path : `/${path}`; + return { + method: method.toUpperCase(), + url: origin ? `${origin}${suffix}` : suffix, + auth: { type: 'none' }, + ...(preferHost ? { hostExecution: { preferHostExecution: true } } : {}), + }; +} + function readViewerDeepLinkState(): ViewerDeepLinkState { if (typeof window === 'undefined') return { tryIt: false }; @@ -91,12 +112,32 @@ export const EndpointDetail: React.FC = ({ spec, path, meth const registered = runtimeSnapshot?.runtimeOnly?.some((route) => route.path === path && route.method.toUpperCase() === method.toUpperCase()) || runtimeSnapshot?.validation?.findings.some((finding) => finding.code === 'runtime.operation-undocumented' && finding.location.path === path && finding.location.method?.toUpperCase() === method.toUpperCase()); if (!registered) return
{messages?.operationNotFound || 'Operation not found.'}
; + const origin = httpOrigin(runtimeSnapshot?.serverOrigin); + const host = options.tryIt?.hostExecution; + const preferHost = host?.available === true && host.preferHostExecution !== false; + const openRuntimeRequest = () => onOpenInApiClient?.({ + request: runtimeRouteRequest(method, path, origin, preferHost), + serverUrl: origin || undefined, + scripts: { preRequest: '', tests: '' }, + requestTab: 'params', + scriptTab: 'pre-request', + }); return
{method.toUpperCase()} {path}
-

{messages?.runtimeRouteUndocumented || 'The running service registers this operation. OpenAPI does not document it.'}

+
+
+
{messages?.contractEvidence || 'Contract'}
+
{messages?.contractNotDeclared || 'OpenAPI does not declare this operation.'}
+
+
+
{messages?.runtimeEvidence || 'Runtime'}
+
{messages?.runtimeRouteUndocumented || `${method.toUpperCase()} ${path} is registered by the running service.`}
+
+
+ {onOpenInApiClient && }
; } if (!sampleRequest) return
{messages?.operationNotFound || 'Operation not found.'}
; diff --git a/packages/client/src/components/FlexDoc.tsx b/packages/client/src/components/FlexDoc.tsx index c1f72e44..4ec81546 100644 --- a/packages/client/src/components/FlexDoc.tsx +++ b/packages/client/src/components/FlexDoc.tsx @@ -215,7 +215,17 @@ export const FlexDoc: React.FC = ({ useEffect(() => { if (typeof window === 'undefined') return; - const syncHash = () => setSelectedEndpoint(endpointFromHash(spec, window.location.hash)); + const syncHash = () => { + const fromSpec = endpointFromHash(spec, window.location.hash); + if (fromSpec) { + setSelectedEndpoint(fromSpec); + return; + } + const hash = window.location.hash.replace(/^#/, ''); + setSelectedEndpoint((current) => ( + current && hash && operationHashId(current.path, current.method) === hash ? current : null + )); + }; const syncView = () => { const nextView = viewFromLocation(); setActiveView(nextView); diff --git a/packages/client/src/components/RuntimeIntelligencePanel.tsx b/packages/client/src/components/RuntimeIntelligencePanel.tsx index 726654f9..37cdf8a4 100644 --- a/packages/client/src/components/RuntimeIntelligencePanel.tsx +++ b/packages/client/src/components/RuntimeIntelligencePanel.tsx @@ -157,7 +157,7 @@ function ValidationFindings({ result, theme, messages, onSelect }: { result: Fle ? (messages?.openRuntimeRoute || 'Open runtime route') : (messages?.openDocumentedOperation || 'Open documented operation'); const content = <> -
{finding.severity.toUpperCase()}{finding.code}
+
{finding.severity.toUpperCase()}{finding.code}{finding.disposition === 'acknowledged' && {messages?.acknowledgedFinding || 'acknowledged'}}
{finding.message}
{(finding.expected !== undefined || finding.observed !== undefined) &&
{finding.expected !== undefined &&
{messages?.validationExpected || 'Expected'}: {validationValue(finding.expected)}
} diff --git a/packages/client/src/types/options.ts b/packages/client/src/types/options.ts index 8589b9f8..e86a881e 100644 --- a/packages/client/src/types/options.ts +++ b/packages/client/src/types/options.ts @@ -182,6 +182,10 @@ export interface FlexDocMessages { /** Status text shown when 3.1 contract validation has no findings. */ contractValidationPass?: string; /** Label preceding expected contract state in a finding. */ validationExpected?: string; /** Label preceding observed runtime state in a finding. */ validationObserved?: string; + /** Label for a finding the operator has accepted. */ acknowledgedFinding?: string; + /** Label for the contract side of a runtime-only route. */ contractEvidence?: string; + /** States that OpenAPI does not declare the selected operation. */ contractNotDeclared?: string; + /** Label for the runtime side of a runtime-only route. */ runtimeEvidence?: string; /** Advisory heading for HTTP methods with unusual request bodies. */ unusualBodyAdvisory?: string; /** Copy explaining that API-host execution can preserve an unusual body. */ unusualBodyHostExecution?: string; /** Copy warning that browser transport may reject an unusual body. */ unusualBodyBrowserWarning?: string; @@ -242,7 +246,7 @@ export interface FlexDocRuntimeEnvironmentMetadata { /** Aggregate route counts in a Runtime Intelligence snapshot. */ export interface FlexDocRuntimeIntelligenceSummary { /** Number of HTTP operations present in the OpenAPI document. */ documented: number; - /** Runtime routes in the drift comparison (`matched + runtimeOnly`). Acknowledged undocumented routes stay in `routes` and are excluded here. */ runtime: number; + /** Number of routes discovered in the running backend, including acknowledged undocumented routes. */ runtime: number; /** Number of routes observed in both OpenAPI and the running backend. */ matched: number; /** Number of runtime routes missing from OpenAPI. */ runtimeOnly: number; /** Number of OpenAPI operations not observed at runtime. */ documentedOnly: number; @@ -274,6 +278,7 @@ export interface FlexDocContractValidationFinding { /** Human-readable explanation. */ message: string; /** Concise expected contract/runtime state. */ expected?: string | string[]; /** Concise state observed in the running backend. */ observed?: string | string[]; + /** Operator policy applied to this finding. Absence means the finding is still actionable. */ disposition?: 'acknowledged'; } /** Aggregate finding counts for one runtime contract-validation pass. */ diff --git a/packages/client/src/utils/runtime-intelligence.ts b/packages/client/src/utils/runtime-intelligence.ts index d30796f5..cf46eb8a 100644 --- a/packages/client/src/utils/runtime-intelligence.ts +++ b/packages/client/src/utils/runtime-intelligence.ts @@ -90,6 +90,10 @@ function validationFinding(value: unknown): FlexDocContractValidationFinding { if (expected !== undefined) finding.expected = expected; const observed = optionalStringOrStrings(value, 'observed'); if (observed !== undefined) finding.observed = observed; + if (value.disposition !== undefined) { + if (value.disposition !== 'acknowledged') invalidSnapshot(); + finding.disposition = 'acknowledged'; + } return finding; } diff --git a/tools/flexdoc-cli/src/validation.js b/tools/flexdoc-cli/src/validation.js index 2a678aa5..df6201d2 100644 --- a/tools/flexdoc-cli/src/validation.js +++ b/tools/flexdoc-cli/src/validation.js @@ -73,6 +73,10 @@ function parseFinding(value) { if (expected !== undefined) finding.expected = expected; const observed = optionalStringOrStrings(value, 'observed'); if (observed !== undefined) finding.observed = observed; + if (value.disposition !== undefined) { + if (value.disposition !== 'acknowledged') invalidValidation('unsupported finding disposition'); + finding.disposition = 'acknowledged'; + } return finding; } @@ -225,7 +229,8 @@ export function formatContractValidationResult(result) { ]; for (const finding of result.findings) { const operation = `${finding.location.method ? `${finding.location.method} ` : ''}${finding.location.path}`; - lines.push('', `[${finding.severity.toUpperCase()}] ${finding.code} · ${operation}`, finding.message); + const disposition = finding.disposition === 'acknowledged' ? ' · acknowledged' : ''; + lines.push('', `[${finding.severity.toUpperCase()}] ${finding.code} · ${operation}${disposition}`, finding.message); if (finding.expected !== undefined) lines.push(`Expected: ${displayValue(finding.expected)}`); if (finding.observed !== undefined) lines.push(`Observed: ${displayValue(finding.observed)}`); }